Bug 1358037 - Inline the methods of nsHtml5ElementName and nsHtml5AttributeName. r=wchen
authorHenri Sivonen <hsivonen@hsivonen.fi>
Thu, 20 Apr 2017 10:34:32 +0300
changeset 356842 2e4c64214e31c3a759918133fbfb6db25f68e33f
parent 356841 5c767e2e3dedaded01efd9eb4f91aeda51717b1b
child 356843 53e95295210a0364bdf9a8f076b61ef4cb2059f5
push id31775
push userihsiao@mozilla.com
push dateMon, 08 May 2017 03:10:38 +0000
treeherdermozilla-central@22aaf8bad4df [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswchen
bugs1358037
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1358037 - Inline the methods of nsHtml5ElementName and nsHtml5AttributeName. r=wchen Moving methods that refer to constant to the header that defines the constants makes it infeasible to #define the constants at the end of the header. To avoid introducing a new pass over the Java AST, this patch turns the primitive constants that were previously #defined into C++ contants, which, according to Stroustrup 3rd ed., are handled at compile-time and don't consume storage. MozReview-Commit-ID: JnaDgW2OM7t
parser/html/javasrc/AttributeName.java
parser/html/javasrc/ElementName.java
parser/html/moz.build
parser/html/nsHtml5AtomList.h
parser/html/nsHtml5AttributeName.cpp
parser/html/nsHtml5AttributeName.h
parser/html/nsHtml5ElementName.cpp
parser/html/nsHtml5ElementName.h
parser/html/nsHtml5Highlighter.cpp
parser/html/nsHtml5HtmlAttributes.cpp
parser/html/nsHtml5MetaScanner.cpp
parser/html/nsHtml5MetaScanner.h
parser/html/nsHtml5Portability.h
parser/html/nsHtml5StackNode.cpp
parser/html/nsHtml5StackNode.h
parser/html/nsHtml5StateSnapshot.cpp
parser/html/nsHtml5StateSnapshot.h
parser/html/nsHtml5Tokenizer.cpp
parser/html/nsHtml5Tokenizer.h
parser/html/nsHtml5TokenizerCppSupplement.h
parser/html/nsHtml5TreeBuilder.cpp
parser/html/nsHtml5TreeBuilder.h
parser/html/nsHtml5TreeBuilderCppSupplement.h
parser/html/nsHtml5UTF16Buffer.cpp
parser/html/nsHtml5UTF16Buffer.h
--- a/parser/html/javasrc/AttributeName.java
+++ b/parser/html/javasrc/AttributeName.java
@@ -265,27 +265,27 @@ public final class AttributeName
      * @param offset
      *            ignored
      * @param length
      *            length of data
      * @param checkNcName
      *            whether to check ncnameness
      * @return an <code>AttributeName</code> corresponding to the argument data
      */
-    static AttributeName nameByBuffer(@NoLength char[] buf, int offset,
+    @Inline static AttributeName nameByBuffer(@NoLength char[] buf, int offset,
             int length
             , Interner interner) {
         // XXX deal with offset
         @Unsigned int hash = AttributeName.bufToHash(buf, length);
         int index = Arrays.binarySearch(AttributeName.ATTRIBUTE_HASHES, hash);
         if (index < 0) {
             return null;
         }
         AttributeName attributeName = AttributeName.ATTRIBUTE_NAMES[index];
-        @Local String name = attributeName.getLocal(AttributeName.HTML);
+        @Local String name = attributeName.getLocal(0);
         if (!Portability.localEqualsBuffer(name, buf, offset, length)) {
             return null;
         }
         return attributeName;
     }
 
     /**
      * This method has to return a unique positive integer for each well-known
@@ -411,21 +411,21 @@ public final class AttributeName
 
     // CPPONLY: public AttributeName() {
     // CPPONLY:     this.uri = AttributeName.ALL_NO_NS;
     // CPPONLY:     this.local = AttributeName.SAME_LOCAL(null);
     // CPPONLY:     this.prefix = ALL_NO_PREFIX;
     // CPPONLY:     this.custom = true;
     // CPPONLY: }
     // CPPONLY:
-    // CPPONLY: public boolean isInterned() {
+    // CPPONLY: @Inline public boolean isInterned() {
     // CPPONLY:     return !custom;
     // CPPONLY: }
     // CPPONLY:
-    // CPPONLY: public void setNameForNonInterned(@Local String name) {
+    // CPPONLY: @Inline public void setNameForNonInterned(@Local String name) {
     // CPPONLY:     assert custom;
     // CPPONLY:     local[0] = name;
     // CPPONLY:     local[1] = name;
     // CPPONLY:     local[2] = name;
     // CPPONLY: }
 
     /**
      * Creates an <code>AttributeName</code> for a local name.
--- a/parser/html/javasrc/ElementName.java
+++ b/parser/html/javasrc/ElementName.java
@@ -100,25 +100,25 @@ public final class ElementName
     @Inline public @Local String getCamelCaseName() {
         return camelCaseName;
     }
 
     @Inline public int getFlags() {
         return flags;
     }
 
-    public int getGroup() {
-        return flags & GROUP_MASK;
+    @Inline public int getGroup() {
+        return flags & ElementName.GROUP_MASK;
     }
 
-    public boolean isInterned() {
-        return (flags & NOT_INTERNED) == 0;
+    @Inline public boolean isInterned() {
+        return (flags & ElementName.NOT_INTERNED) == 0;
     }
 
-    static ElementName elementNameByBuffer(@NoLength char[] buf, int offset, int length, Interner interner) {
+    @Inline static ElementName elementNameByBuffer(@NoLength char[] buf, int offset, int length, Interner interner) {
         @Unsigned int hash = ElementName.bufToHash(buf, length);
         int index = Arrays.binarySearch(ElementName.ELEMENT_HASHES, hash);
         if (index < 0) {
             return null;
         } else {
             ElementName elementName = ElementName.ELEMENT_NAMES[index];
             @Local String name = elementName.name;
             if (!Portability.localEqualsBuffer(name, buf, offset, length)) {
@@ -177,22 +177,25 @@ public final class ElementName
         this.camelCaseName = null;
         this.flags = TreeBuilder.OTHER | NOT_INTERNED;
     }
 
     public void destructor() {
         // The translator adds refcount debug code here.
     }
 
-    public void setNameForNonInterned(@Local String name) {
+    @Inline public void setNameForNonInterned(@Local String name) {
         // No need to worry about refcounting the local name, because in the
         // C++ case the scoped atom table remembers its own atoms.
         this.name = name;
         this.camelCaseName = name;
-        assert this.flags == (TreeBuilder.OTHER | NOT_INTERNED);
+        // The assertion below relies on TreeBuilder.OTHER being zero!
+        // TreeBuilder.OTHER isn't referenced here, because it would create
+        // a circular C++ header dependency given that this method is inlined.
+        assert this.flags == ElementName.NOT_INTERNED;
     }
 
     public static final ElementName ANNOTATION_XML = new ElementName("annotation-xml", "annotation-xml", TreeBuilder.ANNOTATION_XML | SCOPING_AS_MATHML);
 
     // CPPONLY: public static final ElementName ISINDEX = new ElementName("isindex", "isindex", TreeBuilder.ISINDEX | SPECIAL);
     // [NOCPP[
     public static final ElementName ISINDEX = new ElementName("isindex", "isindex", TreeBuilder.OTHER);
     // ]NOCPP]
--- a/parser/html/moz.build
+++ b/parser/html/moz.build
@@ -31,16 +31,17 @@ EXPORTS += [
     'nsHtml5MetaScannerHSupplement.h',
     'nsHtml5Module.h',
     'nsHtml5NamedCharacters.h',
     'nsHtml5NamedCharactersAccel.h',
     'nsHtml5OplessBuilder.h',
     'nsHtml5OwningUTF16Buffer.h',
     'nsHtml5Parser.h',
     'nsHtml5PlainTextUtils.h',
+    'nsHtml5Portability.h',
     'nsHtml5RefPtr.h',
     'nsHtml5Speculation.h',
     'nsHtml5SpeculativeLoad.h',
     'nsHtml5StreamListener.h',
     'nsHtml5StreamParser.h',
     'nsHtml5String.h',
     'nsHtml5StringParser.h',
     'nsHtml5SVGLoadDispatcher.h',
--- a/parser/html/nsHtml5AtomList.h
+++ b/parser/html/nsHtml5AtomList.h
@@ -15,68 +15,16 @@
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
  * DEALINGS IN THE SOFTWARE.
  */
 
-HTML5_ATOM(emptystring, "")
-HTML5_ATOM(title, "title")
-HTML5_ATOM(desc, "desc")
-HTML5_ATOM(foreignObject, "foreignObject")
-HTML5_ATOM(mi, "mi")
-HTML5_ATOM(mo, "mo")
-HTML5_ATOM(mn, "mn")
-HTML5_ATOM(ms, "ms")
-HTML5_ATOM(mtext, "mtext")
-HTML5_ATOM(annotation_xml, "annotation-xml")
-HTML5_ATOM(template_, "template")
-HTML5_ATOM(textarea, "textarea")
-HTML5_ATOM(style, "style")
-HTML5_ATOM(xmp, "xmp")
-HTML5_ATOM(iframe, "iframe")
-HTML5_ATOM(noembed, "noembed")
-HTML5_ATOM(noframes, "noframes")
-HTML5_ATOM(noscript, "noscript")
-HTML5_ATOM(plaintext, "plaintext")
-HTML5_ATOM(script, "script")
-HTML5_ATOM(svg, "svg")
-HTML5_ATOM(table, "table")
-HTML5_ATOM(caption, "caption")
-HTML5_ATOM(p, "p")
-HTML5_ATOM(address, "address")
-HTML5_ATOM(div, "div")
-HTML5_ATOM(a, "a")
-HTML5_ATOM(nobr, "nobr")
-HTML5_ATOM(name, "name")
-HTML5_ATOM(prompt, "prompt")
-HTML5_ATOM(action, "action")
-HTML5_ATOM(input, "input")
-HTML5_ATOM(option, "option")
-HTML5_ATOM(ruby, "ruby")
-HTML5_ATOM(rtc, "rtc")
-HTML5_ATOM(select, "select")
-HTML5_ATOM(optgroup, "optgroup")
-HTML5_ATOM(tbody, "tbody")
-HTML5_ATOM(tfoot, "tfoot")
-HTML5_ATOM(thead, "thead")
-HTML5_ATOM(frameset, "frameset")
-HTML5_ATOM(button, "button")
-HTML5_ATOM(ul, "ul")
-HTML5_ATOM(ol, "ol")
-HTML5_ATOM(html, "html")
-HTML5_ATOM(td, "td")
-HTML5_ATOM(th, "th")
-HTML5_ATOM(tr, "tr")
-HTML5_ATOM(colgroup, "colgroup")
-HTML5_ATOM(head, "head")
-HTML5_ATOM(body, "body")
-HTML5_ATOM(form, "form")
 HTML5_ATOM(xmlns, "xmlns")
 HTML5_ATOM(xlink, "xlink")
 HTML5_ATOM(xml, "xml")
 HTML5_ATOM(alt, "alt")
 HTML5_ATOM(dir, "dir")
 HTML5_ATOM(dur, "dur")
 HTML5_ATOM(end, "end")
 HTML5_ATOM(for_, "for")
@@ -247,16 +195,17 @@ HTML5_ATOM(hidefocus, "hidefocus")
 HTML5_ATOM(index, "index")
 HTML5_ATOM(irrelevant, "irrelevant")
 HTML5_ATOM(intercept, "intercept")
 HTML5_ATOM(integrity, "integrity")
 HTML5_ATOM(linebreak, "linebreak")
 HTML5_ATOM(label, "label")
 HTML5_ATOM(linethickness, "linethickness")
 HTML5_ATOM(mode, "mode")
+HTML5_ATOM(name, "name")
 HTML5_ATOM(noresize, "noresize")
 HTML5_ATOM(onbeforeunload, "onbeforeunload")
 HTML5_ATOM(onrepeat, "onrepeat")
 HTML5_ATOM(object, "object")
 HTML5_ATOM(onselect, "onselect")
 HTML5_ATOM(order, "order")
 HTML5_ATOM(other, "other")
 HTML5_ATOM(onreset, "onreset")
@@ -352,16 +301,17 @@ HTML5_ATOM(mathcolor, "mathcolor")
 HTML5_ATOM(mathsize, "mathsize")
 HTML5_ATOM(noshade, "noshade")
 HTML5_ATOM(onchange, "onchange")
 HTML5_ATOM(pathlength, "pathlength")
 HTML5_ATOM(pathLength, "pathLength")
 HTML5_ATOM(path, "path")
 HTML5_ATOM(altimg, "altimg")
 HTML5_ATOM(actiontype, "actiontype")
+HTML5_ATOM(action, "action")
 HTML5_ATOM(active, "active")
 HTML5_ATOM(additive, "additive")
 HTML5_ATOM(begin, "begin")
 HTML5_ATOM(dominant_baseline, "dominant-baseline")
 HTML5_ATOM(divisor, "divisor")
 HTML5_ATOM(definitionurl, "definitionurl")
 HTML5_ATOM(definitionURL, "definitionURL")
 HTML5_ATOM(horiz_adv_x, "horiz-adv-x")
@@ -410,25 +360,29 @@ HTML5_ATOM(fill_rule, "fill-rule")
 HTML5_ATOM(fill, "fill")
 HTML5_ATOM(fill_opacity, "fill-opacity")
 HTML5_ATOM(maxlength, "maxlength")
 HTML5_ATOM(onclick, "onclick")
 HTML5_ATOM(onblur, "onblur")
 HTML5_ATOM(replace, "replace")
 HTML5_ATOM(rowlines, "rowlines")
 HTML5_ATOM(scale, "scale")
+HTML5_ATOM(style, "style")
 HTML5_ATOM(tablevalues, "tablevalues")
 HTML5_ATOM(tableValues, "tableValues")
+HTML5_ATOM(title, "title")
 HTML5_ATOM(v_alphabetic, "v-alphabetic")
 HTML5_ATOM(azimuth, "azimuth")
 HTML5_ATOM(format, "format")
 HTML5_ATOM(frameborder, "frameborder")
 HTML5_ATOM(frame, "frame")
 HTML5_ATOM(framespacing, "framespacing")
 HTML5_ATOM(from, "from")
+HTML5_ATOM(form, "form")
+HTML5_ATOM(prompt, "prompt")
 HTML5_ATOM(primitiveunits, "primitiveunits")
 HTML5_ATOM(primitiveUnits, "primitiveUnits")
 HTML5_ATOM(symmetric, "symmetric")
 HTML5_ATOM(stemh, "stemh")
 HTML5_ATOM(stemv, "stemv")
 HTML5_ATOM(seamless, "seamless")
 HTML5_ATOM(summary, "summary")
 HTML5_ATOM(usemap, "usemap")
@@ -552,16 +506,17 @@ HTML5_ATOM(property, "property")
 HTML5_ATOM(scoped, "scoped")
 HTML5_ATOM(step, "step")
 HTML5_ATOM(shape_rendering, "shape-rendering")
 HTML5_ATOM(scope, "scope")
 HTML5_ATOM(shape, "shape")
 HTML5_ATOM(slope, "slope")
 HTML5_ATOM(stop_color, "stop-color")
 HTML5_ATOM(stop_opacity, "stop-opacity")
+HTML5_ATOM(template_, "template")
 HTML5_ATOM(wrap, "wrap")
 HTML5_ATOM(abbr, "abbr")
 HTML5_ATOM(attributename, "attributename")
 HTML5_ATOM(attributeName, "attributeName")
 HTML5_ATOM(attributetype, "attributetype")
 HTML5_ATOM(attributeType, "attributeType")
 HTML5_ATOM(char_, "char")
 HTML5_ATOM(coords, "coords")
@@ -708,62 +663,75 @@ HTML5_ATOM(dy, "dy")
 HTML5_ATOM(fy, "fy")
 HTML5_ATOM(ry, "ry")
 HTML5_ATOM(refy, "refy")
 HTML5_ATOM(refY, "refY")
 HTML5_ATOM(verythinmathspace, "verythinmathspace")
 HTML5_ATOM(verythickmathspace, "verythickmathspace")
 HTML5_ATOM(veryverythinmathspace, "veryverythinmathspace")
 HTML5_ATOM(veryverythickmathspace, "veryverythickmathspace")
+HTML5_ATOM(annotation_xml, "annotation-xml")
 HTML5_ATOM(isindex, "isindex")
 HTML5_ATOM(big, "big")
 HTML5_ATOM(bdo, "bdo")
 HTML5_ATOM(col, "col")
 HTML5_ATOM(del, "del")
 HTML5_ATOM(dfn, "dfn")
+HTML5_ATOM(div, "div")
 HTML5_ATOM(img, "img")
 HTML5_ATOM(ins, "ins")
 HTML5_ATOM(kbd, "kbd")
 HTML5_ATOM(map, "map")
 HTML5_ATOM(nav, "nav")
 HTML5_ATOM(pre, "pre")
+HTML5_ATOM(a, "a")
 HTML5_ATOM(b, "b")
+HTML5_ATOM(rtc, "rtc")
 HTML5_ATOM(sub, "sub")
+HTML5_ATOM(svg, "svg")
 HTML5_ATOM(sup, "sup")
 HTML5_ATOM(set, "set")
 HTML5_ATOM(use, "use")
 HTML5_ATOM(var, "var")
 HTML5_ATOM(g, "g")
 HTML5_ATOM(wbr, "wbr")
+HTML5_ATOM(xmp, "xmp")
 HTML5_ATOM(i, "i")
+HTML5_ATOM(p, "p")
 HTML5_ATOM(q, "q")
 HTML5_ATOM(s, "s")
 HTML5_ATOM(u, "u")
 HTML5_ATOM(h1, "h1")
 HTML5_ATOM(h2, "h2")
 HTML5_ATOM(h3, "h3")
 HTML5_ATOM(h4, "h4")
 HTML5_ATOM(h5, "h5")
 HTML5_ATOM(h6, "h6")
 HTML5_ATOM(area, "area")
 HTML5_ATOM(fefunca, "fefunca")
 HTML5_ATOM(feFuncA, "feFuncA")
 HTML5_ATOM(metadata, "metadata")
 HTML5_ATOM(meta, "meta")
+HTML5_ATOM(textarea, "textarea")
 HTML5_ATOM(fefuncb, "fefuncb")
 HTML5_ATOM(feFuncB, "feFuncB")
 HTML5_ATOM(rb, "rb")
+HTML5_ATOM(desc, "desc")
 HTML5_ATOM(dd, "dd")
 HTML5_ATOM(bgsound, "bgsound")
 HTML5_ATOM(embed, "embed")
 HTML5_ATOM(feblend, "feblend")
 HTML5_ATOM(feBlend, "feBlend")
 HTML5_ATOM(feflood, "feflood")
 HTML5_ATOM(feFlood, "feFlood")
+HTML5_ATOM(head, "head")
 HTML5_ATOM(legend, "legend")
+HTML5_ATOM(noembed, "noembed")
+HTML5_ATOM(td, "td")
+HTML5_ATOM(thead, "thead")
 HTML5_ATOM(aside, "aside")
 HTML5_ATOM(article, "article")
 HTML5_ATOM(animate, "animate")
 HTML5_ATOM(blockquote, "blockquote")
 HTML5_ATOM(circle, "circle")
 HTML5_ATOM(ellipse, "ellipse")
 HTML5_ATOM(feturbulence, "feturbulence")
 HTML5_ATOM(feTurbulence, "feTurbulence")
@@ -774,22 +742,24 @@ HTML5_ATOM(feImage, "feImage")
 HTML5_ATOM(femerge, "femerge")
 HTML5_ATOM(feMerge, "feMerge")
 HTML5_ATOM(fetile, "fetile")
 HTML5_ATOM(feTile, "feTile")
 HTML5_ATOM(figure, "figure")
 HTML5_ATOM(fecomposite, "fecomposite")
 HTML5_ATOM(feComposite, "feComposite")
 HTML5_ATOM(image, "image")
+HTML5_ATOM(iframe, "iframe")
 HTML5_ATOM(line, "line")
 HTML5_ATOM(marquee, "marquee")
 HTML5_ATOM(polyline, "polyline")
 HTML5_ATOM(picture, "picture")
 HTML5_ATOM(source, "source")
 HTML5_ATOM(strike, "strike")
+HTML5_ATOM(table, "table")
 HTML5_ATOM(time, "time")
 HTML5_ATOM(altglyphdef, "altglyphdef")
 HTML5_ATOM(altGlyphDef, "altGlyphDef")
 HTML5_ATOM(dialog, "dialog")
 HTML5_ATOM(fefuncg, "fefuncg")
 HTML5_ATOM(feFuncG, "feFuncG")
 HTML5_ATOM(fediffuselighting, "fediffuselighting")
 HTML5_ATOM(feDiffuseLighting, "feDiffuseLighting")
@@ -799,48 +769,60 @@ HTML5_ATOM(listing, "listing")
 HTML5_ATOM(strong, "strong")
 HTML5_ATOM(altglyph, "altglyph")
 HTML5_ATOM(altGlyph, "altGlyph")
 HTML5_ATOM(clippath, "clippath")
 HTML5_ATOM(clipPath, "clipPath")
 HTML5_ATOM(mglyph, "mglyph")
 HTML5_ATOM(math, "math")
 HTML5_ATOM(mpath, "mpath")
+HTML5_ATOM(th, "th")
 HTML5_ATOM(switch_, "switch")
 HTML5_ATOM(textpath, "textpath")
 HTML5_ATOM(textPath, "textPath")
 HTML5_ATOM(li, "li")
+HTML5_ATOM(mi, "mi")
 HTML5_ATOM(mark, "mark")
 HTML5_ATOM(malignmark, "malignmark")
 HTML5_ATOM(track, "track")
 HTML5_ATOM(dl, "dl")
+HTML5_ATOM(html, "html")
+HTML5_ATOM(ol, "ol")
+HTML5_ATOM(ul, "ul")
 HTML5_ATOM(small_, "small")
 HTML5_ATOM(symbol, "symbol")
 HTML5_ATOM(altglyphitem, "altglyphitem")
 HTML5_ATOM(altGlyphItem, "altGlyphItem")
 HTML5_ATOM(animatetransform, "animatetransform")
 HTML5_ATOM(animateTransform, "animateTransform")
 HTML5_ATOM(acronym, "acronym")
 HTML5_ATOM(em, "em")
 HTML5_ATOM(menuitem, "menuitem")
 HTML5_ATOM(param, "param")
 HTML5_ATOM(animatemotion, "animatemotion")
 HTML5_ATOM(animateMotion, "animateMotion")
+HTML5_ATOM(button, "button")
+HTML5_ATOM(caption, "caption")
 HTML5_ATOM(figcaption, "figcaption")
+HTML5_ATOM(mn, "mn")
 HTML5_ATOM(keygen, "keygen")
 HTML5_ATOM(main, "main")
+HTML5_ATOM(option, "option")
 HTML5_ATOM(polygon, "polygon")
 HTML5_ATOM(section, "section")
 HTML5_ATOM(tspan, "tspan")
 HTML5_ATOM(audio, "audio")
+HTML5_ATOM(mo, "mo")
 HTML5_ATOM(video, "video")
+HTML5_ATOM(colgroup, "colgroup")
 HTML5_ATOM(fedisplacementmap, "fedisplacementmap")
 HTML5_ATOM(feDisplacementMap, "feDisplacementMap")
 HTML5_ATOM(hgroup, "hgroup")
 HTML5_ATOM(rp, "rp")
+HTML5_ATOM(optgroup, "optgroup")
 HTML5_ATOM(samp, "samp")
 HTML5_ATOM(stop, "stop")
 HTML5_ATOM(br, "br")
 HTML5_ATOM(animatecolor, "animatecolor")
 HTML5_ATOM(animateColor, "animateColor")
 HTML5_ATOM(center, "center")
 HTML5_ATOM(hr, "hr")
 HTML5_ATOM(fefuncr, "fefuncr")
@@ -848,43 +830,61 @@ HTML5_ATOM(feFuncR, "feFuncR")
 HTML5_ATOM(fecomponenttransfer, "fecomponenttransfer")
 HTML5_ATOM(feComponentTransfer, "feComponentTransfer")
 HTML5_ATOM(footer, "footer")
 HTML5_ATOM(fegaussianblur, "fegaussianblur")
 HTML5_ATOM(feGaussianBlur, "feGaussianBlur")
 HTML5_ATOM(header, "header")
 HTML5_ATOM(marker, "marker")
 HTML5_ATOM(meter, "meter")
+HTML5_ATOM(nobr, "nobr")
+HTML5_ATOM(tr, "tr")
+HTML5_ATOM(address, "address")
 HTML5_ATOM(canvas, "canvas")
 HTML5_ATOM(defs, "defs")
 HTML5_ATOM(details, "details")
+HTML5_ATOM(ms, "ms")
+HTML5_ATOM(noframes, "noframes")
 HTML5_ATOM(progress, "progress")
 HTML5_ATOM(dt, "dt")
 HTML5_ATOM(applet, "applet")
 HTML5_ATOM(basefont, "basefont")
 HTML5_ATOM(foreignobject, "foreignobject")
+HTML5_ATOM(foreignObject, "foreignObject")
 HTML5_ATOM(fieldset, "fieldset")
+HTML5_ATOM(frameset, "frameset")
 HTML5_ATOM(feoffset, "feoffset")
 HTML5_ATOM(feOffset, "feOffset")
 HTML5_ATOM(fespotlight, "fespotlight")
 HTML5_ATOM(feSpotLight, "feSpotLight")
 HTML5_ATOM(fepointlight, "fepointlight")
 HTML5_ATOM(fePointLight, "fePointLight")
 HTML5_ATOM(fedistantlight, "fedistantlight")
 HTML5_ATOM(feDistantLight, "feDistantLight")
 HTML5_ATOM(font, "font")
+HTML5_ATOM(input, "input")
 HTML5_ATOM(lineargradient, "lineargradient")
 HTML5_ATOM(linearGradient, "linearGradient")
+HTML5_ATOM(mtext, "mtext")
+HTML5_ATOM(noscript, "noscript")
 HTML5_ATOM(output, "output")
+HTML5_ATOM(plaintext, "plaintext")
 HTML5_ATOM(tt, "tt")
 HTML5_ATOM(rect, "rect")
 HTML5_ATOM(radialgradient, "radialgradient")
 HTML5_ATOM(radialGradient, "radialGradient")
+HTML5_ATOM(select, "select")
+HTML5_ATOM(script, "script")
+HTML5_ATOM(tfoot, "tfoot")
 HTML5_ATOM(menu, "menu")
 HTML5_ATOM(fedropshadow, "fedropshadow")
 HTML5_ATOM(feDropShadow, "feDropShadow")
 HTML5_ATOM(view, "view")
 HTML5_ATOM(fecolormatrix, "fecolormatrix")
 HTML5_ATOM(feColorMatrix, "feColorMatrix")
 HTML5_ATOM(feconvolvematrix, "feconvolvematrix")
 HTML5_ATOM(feConvolveMatrix, "feConvolveMatrix")
+HTML5_ATOM(body, "body")
 HTML5_ATOM(femorphology, "femorphology")
 HTML5_ATOM(feMorphology, "feMorphology")
+HTML5_ATOM(ruby, "ruby")
+HTML5_ATOM(tbody, "tbody")
+HTML5_ATOM(emptystring, "")
--- a/parser/html/nsHtml5AttributeName.cpp
+++ b/parser/html/nsHtml5AttributeName.cpp
@@ -36,21 +36,22 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Atoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
+#include "nsHtml5Portability.h"
 
+#include "nsHtml5ElementName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5MetaScanner.h"
-#include "nsHtml5ElementName.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5StateSnapshot.h"
 #include "nsHtml5Portability.h"
 
 #include "nsHtml5AttributeName.h"
 
 int32_t* nsHtml5AttributeName::ALL_NO_NS = 0;
@@ -96,33 +97,16 @@ nsHtml5AttributeName::SAME_LOCAL(nsIAtom
 {
   nsIAtom** arr = new nsIAtom*[4];
   arr[0] = name;
   arr[1] = name;
   arr[2] = name;
   return arr;
 }
 
-nsHtml5AttributeName* 
-nsHtml5AttributeName::nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
-{
-  uint32_t hash = nsHtml5AttributeName::bufToHash(buf, length);
-  int32_t index = nsHtml5AttributeName::ATTRIBUTE_HASHES.binarySearch(hash);
-  if (index < 0) {
-    return nullptr;
-  }
-  nsHtml5AttributeName* attributeName =
-    nsHtml5AttributeName::ATTRIBUTE_NAMES[index];
-  nsIAtom* name = attributeName->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML);
-  if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) {
-    return nullptr;
-  }
-  return attributeName;
-}
-
 nsHtml5AttributeName::nsHtml5AttributeName(int32_t* uri,
                                            nsIAtom** local,
                                            nsIAtom** prefix)
   : uri(uri)
   , local(local)
   , prefix(prefix)
   , custom(false)
 {
@@ -133,31 +117,16 @@ nsHtml5AttributeName::nsHtml5AttributeNa
   : uri(nsHtml5AttributeName::ALL_NO_NS)
   , local(nsHtml5AttributeName::SAME_LOCAL(nullptr))
   , prefix(ALL_NO_PREFIX)
   , custom(true)
 {
   MOZ_COUNT_CTOR(nsHtml5AttributeName);
 }
 
-bool
-nsHtml5AttributeName::isInterned()
-{
-  return !custom;
-}
-
-void
-nsHtml5AttributeName::setNameForNonInterned(nsIAtom* name)
-{
-  MOZ_ASSERT(custom);
-  local[0] = name;
-  local[1] = name;
-  local[2] = name;
-}
-
 nsHtml5AttributeName*
 nsHtml5AttributeName::createAttributeName(nsIAtom* name)
 {
   return new nsHtml5AttributeName(nsHtml5AttributeName::ALL_NO_NS,
                                   nsHtml5AttributeName::SAME_LOCAL(name),
                                   ALL_NO_PREFIX);
 }
 
@@ -184,17 +153,18 @@ nsIAtom*
 nsHtml5AttributeName::getPrefix(int32_t mode)
 {
   return prefix[mode];
 }
 
 bool 
 nsHtml5AttributeName::equalsAnother(nsHtml5AttributeName* another)
 {
-  return this->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML) == another->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML);
+  return this->getLocal(nsHtml5AttributeName::HTML) ==
+         another->getLocal(nsHtml5AttributeName::HTML);
 }
 
 nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ALT = nullptr;
 nsHtml5AttributeName* nsHtml5AttributeName::ATTR_DIR = nullptr;
 nsHtml5AttributeName* nsHtml5AttributeName::ATTR_DUR = nullptr;
 nsHtml5AttributeName* nsHtml5AttributeName::ATTR_END = nullptr;
 nsHtml5AttributeName* nsHtml5AttributeName::ATTR_FOR = nullptr;
 nsHtml5AttributeName* nsHtml5AttributeName::ATTR_IN2 = nullptr;
--- a/parser/html/nsHtml5AttributeName.h
+++ b/parser/html/nsHtml5AttributeName.h
@@ -37,23 +37,24 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Atoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
+#include "nsHtml5Portability.h"
 
 class nsHtml5StreamParser;
 
+class nsHtml5ElementName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
-class nsHtml5ElementName;
 class nsHtml5UTF16Buffer;
 class nsHtml5StateSnapshot;
 class nsHtml5Portability;
 
 
 class nsHtml5AttributeName
 {
   public:
@@ -68,17 +69,35 @@ class nsHtml5AttributeName
     static nsIAtom** XMLNS_PREFIX;
     static nsIAtom** XLINK_PREFIX;
     static nsIAtom** XML_PREFIX;
     static nsIAtom** SVG_DIFFERENT(nsIAtom* name, nsIAtom* camel);
     static nsIAtom** MATH_DIFFERENT(nsIAtom* name, nsIAtom* camel);
     static nsIAtom** COLONIFIED_LOCAL(nsIAtom* name, nsIAtom* suffix);
   public:
     static nsIAtom** SAME_LOCAL(nsIAtom* name);
-    static nsHtml5AttributeName* nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
+    inline static nsHtml5AttributeName* nameByBuffer(char16_t* buf,
+                                                     int32_t offset,
+                                                     int32_t length,
+                                                     nsHtml5AtomTable* interner)
+    {
+      uint32_t hash = nsHtml5AttributeName::bufToHash(buf, length);
+      int32_t index = nsHtml5AttributeName::ATTRIBUTE_HASHES.binarySearch(hash);
+      if (index < 0) {
+        return nullptr;
+      }
+      nsHtml5AttributeName* attributeName =
+        nsHtml5AttributeName::ATTRIBUTE_NAMES[index];
+      nsIAtom* name = attributeName->getLocal(0);
+      if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) {
+        return nullptr;
+      }
+      return attributeName;
+    }
+
   private:
     inline static uint32_t bufToHash(char16_t* buf, int32_t length)
     {
       uint32_t len = length;
       uint32_t first = buf[0];
       first <<= 19;
       uint32_t second = 1 << 23;
       uint32_t third = 0;
@@ -103,25 +122,41 @@ class nsHtml5AttributeName
         third <<= 9;
       } else if (length == 2) {
         second = buf[1];
         second <<= 24;
       }
       return len + first + second + third + fourth + fifth + sixth;
     }
 
+  public:
+    static const int32_t HTML = 0;
+
+    static const int32_t MATHML = 1;
+
+    static const int32_t SVG = 2;
+
+  private:
     int32_t* uri;
     nsIAtom** local;
     nsIAtom** prefix;
     bool custom;
     nsHtml5AttributeName(int32_t* uri, nsIAtom** local, nsIAtom** prefix);
   public:
     nsHtml5AttributeName();
-    bool isInterned();
-    void setNameForNonInterned(nsIAtom* name);
+    inline bool isInterned() { return !custom; }
+
+    inline void setNameForNonInterned(nsIAtom* name)
+    {
+      MOZ_ASSERT(custom);
+      local[0] = name;
+      local[1] = name;
+      local[2] = name;
+    }
+
     static nsHtml5AttributeName* createAttributeName(nsIAtom* name);
     ~nsHtml5AttributeName();
     int32_t getUri(int32_t mode);
     nsIAtom* getLocal(int32_t mode);
     nsIAtom* getPrefix(int32_t mode);
     bool equalsAnother(nsHtml5AttributeName* another);
     static nsHtml5AttributeName* ATTR_ALT;
     static nsHtml5AttributeName* ATTR_DIR;
@@ -709,15 +744,10 @@ class nsHtml5AttributeName
   private:
     static nsHtml5AttributeName** ATTRIBUTE_NAMES;
     static staticJArray<int32_t,int32_t> ATTRIBUTE_HASHES;
   public:
     static void initializeStatics();
     static void releaseStatics();
 };
 
-#define NS_HTML5ATTRIBUTE_NAME_HTML 0
-#define NS_HTML5ATTRIBUTE_NAME_MATHML 1
-#define NS_HTML5ATTRIBUTE_NAME_SVG 2
-
-
 #endif
 
--- a/parser/html/nsHtml5ElementName.cpp
+++ b/parser/html/nsHtml5ElementName.cpp
@@ -36,89 +36,52 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Atoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
+#include "nsHtml5Portability.h"
 
+#include "nsHtml5AttributeName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5MetaScanner.h"
-#include "nsHtml5AttributeName.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5StateSnapshot.h"
 #include "nsHtml5Portability.h"
 
 #include "nsHtml5ElementName.h"
 
-int32_t 
-nsHtml5ElementName::getGroup()
-{
-  return flags & NS_HTML5ELEMENT_NAME_GROUP_MASK;
-}
-
-bool
-nsHtml5ElementName::isInterned()
-{
-  return !(flags & NS_HTML5ELEMENT_NAME_NOT_INTERNED);
-}
-
-nsHtml5ElementName* 
-nsHtml5ElementName::elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
-{
-  uint32_t hash = nsHtml5ElementName::bufToHash(buf, length);
-  int32_t index = nsHtml5ElementName::ELEMENT_HASHES.binarySearch(hash);
-  if (index < 0) {
-    return nullptr;
-  } else {
-    nsHtml5ElementName* elementName = nsHtml5ElementName::ELEMENT_NAMES[index];
-    nsIAtom* name = elementName->name;
-    if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) {
-      return nullptr;
-    }
-    return elementName;
-  }
-}
-
 
 nsHtml5ElementName::nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, int32_t flags)
   : name(name),
     camelCaseName(camelCaseName),
     flags(flags)
 {
   MOZ_COUNT_CTOR(nsHtml5ElementName);
 }
 
 nsHtml5ElementName::nsHtml5ElementName()
   : name(nullptr)
   , camelCaseName(nullptr)
-  , flags(NS_HTML5TREE_BUILDER_OTHER | NS_HTML5ELEMENT_NAME_NOT_INTERNED)
+  , flags(nsHtml5TreeBuilder::OTHER | NOT_INTERNED)
 {
   MOZ_COUNT_CTOR(nsHtml5ElementName);
 }
 
 
 nsHtml5ElementName::~nsHtml5ElementName()
 {
   MOZ_COUNT_DTOR(nsHtml5ElementName);
 }
 
-void
-nsHtml5ElementName::setNameForNonInterned(nsIAtom* name)
-{
-  this->name = name;
-  this->camelCaseName = name;
-  MOZ_ASSERT(this->flags ==
-             (NS_HTML5TREE_BUILDER_OTHER | NS_HTML5ELEMENT_NAME_NOT_INTERNED));
-}
-
 nsHtml5ElementName* nsHtml5ElementName::ELT_ANNOTATION_XML = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_ISINDEX = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_BIG = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_BDO = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_COL = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_DEL = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_DFN = nullptr;
 nsHtml5ElementName* nsHtml5ElementName::ELT_DIR = nullptr;
@@ -355,621 +318,690 @@ static int32_t const ELEMENT_HASHES_DATA
   2006974466, 2007601444, 2007781534, 2008125638, 2008340774, 2008851557,
   2008994116, 2021937364, 2051837468, 2060065124, 2068523853, 2068523856,
   2070023911, 2083120164, 2085266636, 2091479332, 2092255447, 2092557349
 };
 staticJArray<int32_t,int32_t> nsHtml5ElementName::ELEMENT_HASHES = { ELEMENT_HASHES_DATA, MOZ_ARRAY_LENGTH(ELEMENT_HASHES_DATA) };
 void
 nsHtml5ElementName::initializeStatics()
 {
-  ELT_ANNOTATION_XML =
-    new nsHtml5ElementName(nsHtml5Atoms::annotation_xml,
-                           nsHtml5Atoms::annotation_xml,
-                           NS_HTML5TREE_BUILDER_ANNOTATION_XML |
-                             NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
+  ELT_ANNOTATION_XML = new nsHtml5ElementName(
+    nsHtml5Atoms::annotation_xml,
+    nsHtml5Atoms::annotation_xml,
+    nsHtml5TreeBuilder::ANNOTATION_XML | SCOPING_AS_MATHML);
   ELT_ISINDEX = new nsHtml5ElementName(nsHtml5Atoms::isindex,
                                        nsHtml5Atoms::isindex,
-                                       NS_HTML5TREE_BUILDER_ISINDEX |
-                                         NS_HTML5ELEMENT_NAME_SPECIAL);
-  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);
-  ELT_COL = new nsHtml5ElementName(nsHtml5Atoms::col, nsHtml5Atoms::col, NS_HTML5TREE_BUILDER_COL | NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_DEL = new nsHtml5ElementName(nsHtml5Atoms::del, nsHtml5Atoms::del, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_DFN = new nsHtml5ElementName(nsHtml5Atoms::dfn, nsHtml5Atoms::dfn, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_DIR = new nsHtml5ElementName(nsHtml5Atoms::dir, nsHtml5Atoms::dir, NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_DIV = new nsHtml5ElementName(nsHtml5Atoms::div, nsHtml5Atoms::div, NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_IMG = new nsHtml5ElementName(nsHtml5Atoms::img, nsHtml5Atoms::img, NS_HTML5TREE_BUILDER_IMG | NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_INS = new nsHtml5ElementName(nsHtml5Atoms::ins, nsHtml5Atoms::ins, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_KBD = new nsHtml5ElementName(nsHtml5Atoms::kbd, nsHtml5Atoms::kbd, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_MAP = new nsHtml5ElementName(nsHtml5Atoms::map, nsHtml5Atoms::map, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_NAV = new nsHtml5ElementName(nsHtml5Atoms::nav, nsHtml5Atoms::nav, NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_PRE = new nsHtml5ElementName(nsHtml5Atoms::pre, nsHtml5Atoms::pre, NS_HTML5TREE_BUILDER_PRE_OR_LISTING | NS_HTML5ELEMENT_NAME_SPECIAL);
+                                       nsHtml5TreeBuilder::ISINDEX | SPECIAL);
+  ELT_BIG = new nsHtml5ElementName(
+    nsHtml5Atoms::big,
+    nsHtml5Atoms::big,
+    nsHtml5TreeBuilder::
+      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+  ELT_BDO = new nsHtml5ElementName(
+    nsHtml5Atoms::bdo, nsHtml5Atoms::bdo, nsHtml5TreeBuilder::OTHER);
+  ELT_COL = new nsHtml5ElementName(
+    nsHtml5Atoms::col, nsHtml5Atoms::col, nsHtml5TreeBuilder::COL | SPECIAL);
+  ELT_DEL = new nsHtml5ElementName(
+    nsHtml5Atoms::del, nsHtml5Atoms::del, nsHtml5TreeBuilder::OTHER);
+  ELT_DFN = new nsHtml5ElementName(
+    nsHtml5Atoms::dfn, nsHtml5Atoms::dfn, nsHtml5TreeBuilder::OTHER);
+  ELT_DIR = new nsHtml5ElementName(
+    nsHtml5Atoms::dir,
+    nsHtml5Atoms::dir,
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
+  ELT_DIV = new nsHtml5ElementName(
+    nsHtml5Atoms::div,
+    nsHtml5Atoms::div,
+    nsHtml5TreeBuilder::DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
+  ELT_IMG = new nsHtml5ElementName(
+    nsHtml5Atoms::img, nsHtml5Atoms::img, nsHtml5TreeBuilder::IMG | SPECIAL);
+  ELT_INS = new nsHtml5ElementName(
+    nsHtml5Atoms::ins, nsHtml5Atoms::ins, nsHtml5TreeBuilder::OTHER);
+  ELT_KBD = new nsHtml5ElementName(
+    nsHtml5Atoms::kbd, nsHtml5Atoms::kbd, nsHtml5TreeBuilder::OTHER);
+  ELT_MAP = new nsHtml5ElementName(
+    nsHtml5Atoms::map, nsHtml5Atoms::map, nsHtml5TreeBuilder::OTHER);
+  ELT_NAV = new nsHtml5ElementName(
+    nsHtml5Atoms::nav,
+    nsHtml5Atoms::nav,
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
+  ELT_PRE =
+    new nsHtml5ElementName(nsHtml5Atoms::pre,
+                           nsHtml5Atoms::pre,
+                           nsHtml5TreeBuilder::PRE_OR_LISTING | SPECIAL);
   ELT_A = new nsHtml5ElementName(
-    nsHtml5Atoms::a, nsHtml5Atoms::a, NS_HTML5TREE_BUILDER_A);
+    nsHtml5Atoms::a, nsHtml5Atoms::a, nsHtml5TreeBuilder::A);
   ELT_B = new nsHtml5ElementName(
     nsHtml5Atoms::b,
     nsHtml5Atoms::b,
-    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_RTC = new nsHtml5ElementName(nsHtml5Atoms::rtc, nsHtml5Atoms::rtc, NS_HTML5TREE_BUILDER_RB_OR_RTC | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
-  ELT_SUB = new nsHtml5ElementName(nsHtml5Atoms::sub, nsHtml5Atoms::sub, NS_HTML5TREE_BUILDER_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
-  ELT_SVG = new nsHtml5ElementName(nsHtml5Atoms::svg, nsHtml5Atoms::svg, NS_HTML5TREE_BUILDER_SVG);
-  ELT_SUP = new nsHtml5ElementName(nsHtml5Atoms::sup, nsHtml5Atoms::sup, NS_HTML5TREE_BUILDER_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
-  ELT_SET = new nsHtml5ElementName(nsHtml5Atoms::set, nsHtml5Atoms::set, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_USE = new nsHtml5ElementName(nsHtml5Atoms::use, nsHtml5Atoms::use, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_VAR = new nsHtml5ElementName(nsHtml5Atoms::var, nsHtml5Atoms::var, NS_HTML5TREE_BUILDER_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
+    nsHtml5TreeBuilder::
+      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+  ELT_RTC =
+    new nsHtml5ElementName(nsHtml5Atoms::rtc,
+                           nsHtml5Atoms::rtc,
+                           nsHtml5TreeBuilder::RB_OR_RTC | OPTIONAL_END_TAG);
+  ELT_SUB = new nsHtml5ElementName(
+    nsHtml5Atoms::sub,
+    nsHtml5Atoms::sub,
+    nsHtml5TreeBuilder::RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
+  ELT_SVG = new nsHtml5ElementName(
+    nsHtml5Atoms::svg, nsHtml5Atoms::svg, nsHtml5TreeBuilder::SVG);
+  ELT_SUP = new nsHtml5ElementName(
+    nsHtml5Atoms::sup,
+    nsHtml5Atoms::sup,
+    nsHtml5TreeBuilder::RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
+  ELT_SET = new nsHtml5ElementName(
+    nsHtml5Atoms::set, nsHtml5Atoms::set, nsHtml5TreeBuilder::OTHER);
+  ELT_USE = new nsHtml5ElementName(
+    nsHtml5Atoms::use, nsHtml5Atoms::use, nsHtml5TreeBuilder::OTHER);
+  ELT_VAR = new nsHtml5ElementName(
+    nsHtml5Atoms::var,
+    nsHtml5Atoms::var,
+    nsHtml5TreeBuilder::RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
   ELT_G = new nsHtml5ElementName(
-    nsHtml5Atoms::g, nsHtml5Atoms::g, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_WBR = new nsHtml5ElementName(nsHtml5Atoms::wbr, nsHtml5Atoms::wbr, NS_HTML5TREE_BUILDER_AREA_OR_WBR | NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_XMP = new nsHtml5ElementName(nsHtml5Atoms::xmp, nsHtml5Atoms::xmp, NS_HTML5TREE_BUILDER_XMP | NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5Atoms::g, nsHtml5Atoms::g, nsHtml5TreeBuilder::OTHER);
+  ELT_WBR = new nsHtml5ElementName(nsHtml5Atoms::wbr,
+                                   nsHtml5Atoms::wbr,
+                                   nsHtml5TreeBuilder::AREA_OR_WBR | SPECIAL);
+  ELT_XMP = new nsHtml5ElementName(
+    nsHtml5Atoms::xmp, nsHtml5Atoms::xmp, nsHtml5TreeBuilder::XMP | SPECIAL);
   ELT_I = new nsHtml5ElementName(
     nsHtml5Atoms::i,
     nsHtml5Atoms::i,
-    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_P = new nsHtml5ElementName(nsHtml5Atoms::p,
-                                 nsHtml5Atoms::p,
-                                 NS_HTML5TREE_BUILDER_P |
-                                   NS_HTML5ELEMENT_NAME_SPECIAL |
-                                   NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+    nsHtml5TreeBuilder::
+      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+  ELT_P =
+    new nsHtml5ElementName(nsHtml5Atoms::p,
+                           nsHtml5Atoms::p,
+                           nsHtml5TreeBuilder::P | SPECIAL | OPTIONAL_END_TAG);
   ELT_Q = new nsHtml5ElementName(
-    nsHtml5Atoms::q, nsHtml5Atoms::q, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::q, nsHtml5Atoms::q, nsHtml5TreeBuilder::OTHER);
   ELT_S = new nsHtml5ElementName(
     nsHtml5Atoms::s,
     nsHtml5Atoms::s,
-    NS_HTML5TREE_BUILDER_B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+    nsHtml5TreeBuilder::
+      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_U = new nsHtml5ElementName(
     nsHtml5Atoms::u,
     nsHtml5Atoms::u,
-    NS_HTML5TREE_BUILDER_B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+    nsHtml5TreeBuilder::
+      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_H1 = new nsHtml5ElementName(
     nsHtml5Atoms::h1,
     nsHtml5Atoms::h1,
-    NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
   ELT_H2 = new nsHtml5ElementName(
     nsHtml5Atoms::h2,
     nsHtml5Atoms::h2,
-    NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
   ELT_H3 = new nsHtml5ElementName(
     nsHtml5Atoms::h3,
     nsHtml5Atoms::h3,
-    NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
   ELT_H4 = new nsHtml5ElementName(
     nsHtml5Atoms::h4,
     nsHtml5Atoms::h4,
-    NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
   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);
+    nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | 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_AREA = new nsHtml5ElementName(nsHtml5Atoms::area, nsHtml5Atoms::area, NS_HTML5TREE_BUILDER_AREA_OR_WBR | NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 | SPECIAL);
+  ELT_AREA = new nsHtml5ElementName(nsHtml5Atoms::area,
+                                    nsHtml5Atoms::area,
+                                    nsHtml5TreeBuilder::AREA_OR_WBR | SPECIAL);
   ELT_FEFUNCA = new nsHtml5ElementName(
-    nsHtml5Atoms::fefunca, nsHtml5Atoms::feFuncA, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::fefunca, nsHtml5Atoms::feFuncA, nsHtml5TreeBuilder::OTHER);
   ELT_METADATA = new nsHtml5ElementName(
-    nsHtml5Atoms::metadata, nsHtml5Atoms::metadata, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_META = new nsHtml5ElementName(nsHtml5Atoms::meta, nsHtml5Atoms::meta, NS_HTML5TREE_BUILDER_META | NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5Atoms::metadata, nsHtml5Atoms::metadata, nsHtml5TreeBuilder::OTHER);
+  ELT_META = new nsHtml5ElementName(
+    nsHtml5Atoms::meta, nsHtml5Atoms::meta, nsHtml5TreeBuilder::META | SPECIAL);
   ELT_TEXTAREA = new nsHtml5ElementName(nsHtml5Atoms::textarea,
                                         nsHtml5Atoms::textarea,
-                                        NS_HTML5TREE_BUILDER_TEXTAREA |
-                                          NS_HTML5ELEMENT_NAME_SPECIAL);
+                                        nsHtml5TreeBuilder::TEXTAREA | SPECIAL);
   ELT_FEFUNCB = new nsHtml5ElementName(
-    nsHtml5Atoms::fefuncb, nsHtml5Atoms::feFuncB, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_RB = new nsHtml5ElementName(nsHtml5Atoms::rb,
-                                  nsHtml5Atoms::rb,
-                                  NS_HTML5TREE_BUILDER_RB_OR_RTC |
-                                    NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+    nsHtml5Atoms::fefuncb, nsHtml5Atoms::feFuncB, nsHtml5TreeBuilder::OTHER);
+  ELT_RB =
+    new nsHtml5ElementName(nsHtml5Atoms::rb,
+                           nsHtml5Atoms::rb,
+                           nsHtml5TreeBuilder::RB_OR_RTC | OPTIONAL_END_TAG);
   ELT_DESC = new nsHtml5ElementName(nsHtml5Atoms::desc,
                                     nsHtml5Atoms::desc,
-                                    NS_HTML5TREE_BUILDER_FOREIGNOBJECT_OR_DESC |
-                                      NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG);
+                                    nsHtml5TreeBuilder::FOREIGNOBJECT_OR_DESC |
+                                      SCOPING_AS_SVG);
   ELT_DD = new nsHtml5ElementName(nsHtml5Atoms::dd,
                                   nsHtml5Atoms::dd,
-                                  NS_HTML5TREE_BUILDER_DD_OR_DT |
-                                    NS_HTML5ELEMENT_NAME_SPECIAL |
-                                    NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
-  ELT_BGSOUND =
-    new nsHtml5ElementName(nsHtml5Atoms::bgsound,
-                           nsHtml5Atoms::bgsound,
-                           NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND |
-                             NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_EMBED = new nsHtml5ElementName(nsHtml5Atoms::embed, nsHtml5Atoms::embed, NS_HTML5TREE_BUILDER_EMBED | NS_HTML5ELEMENT_NAME_SPECIAL);
+                                  nsHtml5TreeBuilder::DD_OR_DT | SPECIAL |
+                                    OPTIONAL_END_TAG);
+  ELT_BGSOUND = new nsHtml5ElementName(
+    nsHtml5Atoms::bgsound,
+    nsHtml5Atoms::bgsound,
+    nsHtml5TreeBuilder::LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
+  ELT_EMBED = new nsHtml5ElementName(nsHtml5Atoms::embed,
+                                     nsHtml5Atoms::embed,
+                                     nsHtml5TreeBuilder::EMBED | SPECIAL);
   ELT_FEBLEND = new nsHtml5ElementName(
-    nsHtml5Atoms::feblend, nsHtml5Atoms::feBlend, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::feblend, nsHtml5Atoms::feBlend, nsHtml5TreeBuilder::OTHER);
   ELT_FEFLOOD = new nsHtml5ElementName(
-    nsHtml5Atoms::feflood, nsHtml5Atoms::feFlood, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::feflood, nsHtml5Atoms::feFlood, nsHtml5TreeBuilder::OTHER);
   ELT_HEAD = new nsHtml5ElementName(nsHtml5Atoms::head,
                                     nsHtml5Atoms::head,
-                                    NS_HTML5TREE_BUILDER_HEAD |
-                                      NS_HTML5ELEMENT_NAME_SPECIAL |
-                                      NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+                                    nsHtml5TreeBuilder::HEAD | SPECIAL |
+                                      OPTIONAL_END_TAG);
   ELT_LEGEND = new nsHtml5ElementName(
-    nsHtml5Atoms::legend, nsHtml5Atoms::legend, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::legend, nsHtml5Atoms::legend, nsHtml5TreeBuilder::OTHER);
   ELT_NOEMBED = new nsHtml5ElementName(nsHtml5Atoms::noembed,
                                        nsHtml5Atoms::noembed,
-                                       NS_HTML5TREE_BUILDER_NOEMBED |
-                                         NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_TD = new nsHtml5ElementName(
-    nsHtml5Atoms::td,
-    nsHtml5Atoms::td,
-    NS_HTML5TREE_BUILDER_TD_OR_TH | NS_HTML5ELEMENT_NAME_SPECIAL |
-      NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
-  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 | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+                                       nsHtml5TreeBuilder::NOEMBED | SPECIAL);
+  ELT_TD = new nsHtml5ElementName(nsHtml5Atoms::td,
+                                  nsHtml5Atoms::td,
+                                  nsHtml5TreeBuilder::TD_OR_TH | SPECIAL |
+                                    SCOPING | OPTIONAL_END_TAG);
+  ELT_THEAD =
+    new nsHtml5ElementName(nsHtml5Atoms::thead,
+                           nsHtml5Atoms::thead,
+                           nsHtml5TreeBuilder::TBODY_OR_THEAD_OR_TFOOT |
+                             SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
   ELT_ASIDE = new nsHtml5ElementName(
     nsHtml5Atoms::aside,
     nsHtml5Atoms::aside,
-    NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
   ELT_ARTICLE = new nsHtml5ElementName(
     nsHtml5Atoms::article,
     nsHtml5Atoms::article,
-    NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
   ELT_ANIMATE = new nsHtml5ElementName(
-    nsHtml5Atoms::animate, nsHtml5Atoms::animate, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_BASE = new nsHtml5ElementName(nsHtml5Atoms::base,
-                                    nsHtml5Atoms::base,
-                                    NS_HTML5TREE_BUILDER_BASE |
-                                      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5Atoms::animate, nsHtml5Atoms::animate, nsHtml5TreeBuilder::OTHER);
+  ELT_BASE = new nsHtml5ElementName(
+    nsHtml5Atoms::base, nsHtml5Atoms::base, nsHtml5TreeBuilder::BASE | SPECIAL);
   ELT_BLOCKQUOTE = new nsHtml5ElementName(
     nsHtml5Atoms::blockquote,
     nsHtml5Atoms::blockquote,
-    NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
   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_CIRCLE = new nsHtml5ElementName(nsHtml5Atoms::circle, nsHtml5Atoms::circle, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5TreeBuilder::
+      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+  ELT_CIRCLE = new nsHtml5ElementName(
+    nsHtml5Atoms::circle, nsHtml5Atoms::circle, nsHtml5TreeBuilder::OTHER);
   ELT_CITE = new nsHtml5ElementName(
-    nsHtml5Atoms::cite, nsHtml5Atoms::cite, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::cite, nsHtml5Atoms::cite, nsHtml5TreeBuilder::OTHER);
   ELT_ELLIPSE = new nsHtml5ElementName(
-    nsHtml5Atoms::ellipse, nsHtml5Atoms::ellipse, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::ellipse, nsHtml5Atoms::ellipse, nsHtml5TreeBuilder::OTHER);
   ELT_FETURBULENCE = new nsHtml5ElementName(nsHtml5Atoms::feturbulence,
                                             nsHtml5Atoms::feTurbulence,
-                                            NS_HTML5TREE_BUILDER_OTHER);
+                                            nsHtml5TreeBuilder::OTHER);
   ELT_FEMERGENODE = new nsHtml5ElementName(nsHtml5Atoms::femergenode,
                                            nsHtml5Atoms::feMergeNode,
-                                           NS_HTML5TREE_BUILDER_OTHER);
+                                           nsHtml5TreeBuilder::OTHER);
   ELT_FEIMAGE = new nsHtml5ElementName(
-    nsHtml5Atoms::feimage, nsHtml5Atoms::feImage, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::feimage, nsHtml5Atoms::feImage, nsHtml5TreeBuilder::OTHER);
   ELT_FEMERGE = new nsHtml5ElementName(
-    nsHtml5Atoms::femerge, nsHtml5Atoms::feMerge, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_FETILE = new nsHtml5ElementName(nsHtml5Atoms::fetile, nsHtml5Atoms::feTile, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::femerge, nsHtml5Atoms::feMerge, nsHtml5TreeBuilder::OTHER);
+  ELT_FETILE = new nsHtml5ElementName(
+    nsHtml5Atoms::fetile, nsHtml5Atoms::feTile, nsHtml5TreeBuilder::OTHER);
   ELT_FRAME = new nsHtml5ElementName(nsHtml5Atoms::frame,
                                      nsHtml5Atoms::frame,
-                                     NS_HTML5TREE_BUILDER_FRAME |
-                                       NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_FIGURE = new nsHtml5ElementName(nsHtml5Atoms::figure, nsHtml5Atoms::figure, NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | NS_HTML5ELEMENT_NAME_SPECIAL);
+                                     nsHtml5TreeBuilder::FRAME | SPECIAL);
+  ELT_FIGURE = new nsHtml5ElementName(
+    nsHtml5Atoms::figure,
+    nsHtml5Atoms::figure,
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
   ELT_FECOMPOSITE = new nsHtml5ElementName(nsHtml5Atoms::fecomposite,
                                            nsHtml5Atoms::feComposite,
-                                           NS_HTML5TREE_BUILDER_OTHER);
+                                           nsHtml5TreeBuilder::OTHER);
   ELT_IMAGE = new nsHtml5ElementName(
-    nsHtml5Atoms::image, nsHtml5Atoms::image, NS_HTML5TREE_BUILDER_IMAGE);
-  ELT_IFRAME = new nsHtml5ElementName(nsHtml5Atoms::iframe, nsHtml5Atoms::iframe, NS_HTML5TREE_BUILDER_IFRAME | NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5Atoms::image, nsHtml5Atoms::image, nsHtml5TreeBuilder::IMAGE);
+  ELT_IFRAME = new nsHtml5ElementName(nsHtml5Atoms::iframe,
+                                      nsHtml5Atoms::iframe,
+                                      nsHtml5TreeBuilder::IFRAME | SPECIAL);
   ELT_LINE = new nsHtml5ElementName(
-    nsHtml5Atoms::line, nsHtml5Atoms::line, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::line, nsHtml5Atoms::line, nsHtml5TreeBuilder::OTHER);
   ELT_MARQUEE = new nsHtml5ElementName(nsHtml5Atoms::marquee,
                                        nsHtml5Atoms::marquee,
-                                       NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET |
-                                         NS_HTML5ELEMENT_NAME_SPECIAL |
-                                         NS_HTML5ELEMENT_NAME_SCOPING);
+                                       nsHtml5TreeBuilder::MARQUEE_OR_APPLET |
+                                         SPECIAL | SCOPING);
   ELT_POLYLINE = new nsHtml5ElementName(
-    nsHtml5Atoms::polyline, nsHtml5Atoms::polyline, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::polyline, nsHtml5Atoms::polyline, nsHtml5TreeBuilder::OTHER);
   ELT_PICTURE = new nsHtml5ElementName(
-    nsHtml5Atoms::picture, nsHtml5Atoms::picture, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_SOURCE = new nsHtml5ElementName(nsHtml5Atoms::source, nsHtml5Atoms::source, NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE_OR_TRACK);
-  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);
+    nsHtml5Atoms::picture, nsHtml5Atoms::picture, nsHtml5TreeBuilder::OTHER);
+  ELT_SOURCE =
+    new nsHtml5ElementName(nsHtml5Atoms::source,
+                           nsHtml5Atoms::source,
+                           nsHtml5TreeBuilder::PARAM_OR_SOURCE_OR_TRACK);
+  ELT_STRIKE = new nsHtml5ElementName(
+    nsHtml5Atoms::strike,
+    nsHtml5Atoms::strike,
+    nsHtml5TreeBuilder::
+      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_STYLE = new nsHtml5ElementName(nsHtml5Atoms::style,
                                      nsHtml5Atoms::style,
-                                     NS_HTML5TREE_BUILDER_STYLE |
-                                       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);
+                                     nsHtml5TreeBuilder::STYLE | SPECIAL);
+  ELT_TABLE = new nsHtml5ElementName(nsHtml5Atoms::table,
+                                     nsHtml5Atoms::table,
+                                     nsHtml5TreeBuilder::TABLE | SPECIAL |
+                                       FOSTER_PARENTING | SCOPING);
   ELT_TITLE = new nsHtml5ElementName(nsHtml5Atoms::title,
                                      nsHtml5Atoms::title,
-                                     NS_HTML5TREE_BUILDER_TITLE |
-                                       NS_HTML5ELEMENT_NAME_SPECIAL |
-                                       NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG);
+                                     nsHtml5TreeBuilder::TITLE | SPECIAL |
+                                       SCOPING_AS_SVG);
   ELT_TIME = new nsHtml5ElementName(
-    nsHtml5Atoms::time, nsHtml5Atoms::time, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_TEMPLATE = new nsHtml5ElementName(nsHtml5Atoms::template_,
-                                        nsHtml5Atoms::template_,
-                                        NS_HTML5TREE_BUILDER_TEMPLATE |
-                                          NS_HTML5ELEMENT_NAME_SPECIAL |
-                                          NS_HTML5ELEMENT_NAME_SCOPING);
+    nsHtml5Atoms::time, nsHtml5Atoms::time, nsHtml5TreeBuilder::OTHER);
+  ELT_TEMPLATE =
+    new nsHtml5ElementName(nsHtml5Atoms::template_,
+                           nsHtml5Atoms::template_,
+                           nsHtml5TreeBuilder::TEMPLATE | SPECIAL | SCOPING);
   ELT_ALTGLYPHDEF = new nsHtml5ElementName(nsHtml5Atoms::altglyphdef,
                                            nsHtml5Atoms::altGlyphDef,
-                                           NS_HTML5TREE_BUILDER_OTHER);
+                                           nsHtml5TreeBuilder::OTHER);
   ELT_GLYPHREF = new nsHtml5ElementName(
-    nsHtml5Atoms::glyphref, nsHtml5Atoms::glyphRef, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::glyphref, nsHtml5Atoms::glyphRef, nsHtml5TreeBuilder::OTHER);
   ELT_DIALOG = new nsHtml5ElementName(
     nsHtml5Atoms::dialog,
     nsHtml5Atoms::dialog,
-    NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
   ELT_FEFUNCG = new nsHtml5ElementName(
-    nsHtml5Atoms::fefuncg, nsHtml5Atoms::feFuncG, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::fefuncg, nsHtml5Atoms::feFuncG, nsHtml5TreeBuilder::OTHER);
   ELT_FEDIFFUSELIGHTING =
     new nsHtml5ElementName(nsHtml5Atoms::fediffuselighting,
                            nsHtml5Atoms::feDiffuseLighting,
-                           NS_HTML5TREE_BUILDER_OTHER);
+                           nsHtml5TreeBuilder::OTHER);
   ELT_FESPECULARLIGHTING =
     new nsHtml5ElementName(nsHtml5Atoms::fespecularlighting,
                            nsHtml5Atoms::feSpecularLighting,
-                           NS_HTML5TREE_BUILDER_OTHER);
-  ELT_LISTING = new nsHtml5ElementName(nsHtml5Atoms::listing,
-                                       nsHtml5Atoms::listing,
-                                       NS_HTML5TREE_BUILDER_PRE_OR_LISTING |
-                                         NS_HTML5ELEMENT_NAME_SPECIAL);
-  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);
+                           nsHtml5TreeBuilder::OTHER);
+  ELT_LISTING =
+    new nsHtml5ElementName(nsHtml5Atoms::listing,
+                           nsHtml5Atoms::listing,
+                           nsHtml5TreeBuilder::PRE_OR_LISTING | SPECIAL);
+  ELT_STRONG = new nsHtml5ElementName(
+    nsHtml5Atoms::strong,
+    nsHtml5Atoms::strong,
+    nsHtml5TreeBuilder::
+      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_ALTGLYPH = new nsHtml5ElementName(
-    nsHtml5Atoms::altglyph, nsHtml5Atoms::altGlyph, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::altglyph, nsHtml5Atoms::altGlyph, nsHtml5TreeBuilder::OTHER);
   ELT_CLIPPATH = new nsHtml5ElementName(
-    nsHtml5Atoms::clippath, nsHtml5Atoms::clipPath, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_MGLYPH =
-    new nsHtml5ElementName(nsHtml5Atoms::mglyph,
-                           nsHtml5Atoms::mglyph,
-                           NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK);
+    nsHtml5Atoms::clippath, nsHtml5Atoms::clipPath, nsHtml5TreeBuilder::OTHER);
+  ELT_MGLYPH = new nsHtml5ElementName(nsHtml5Atoms::mglyph,
+                                      nsHtml5Atoms::mglyph,
+                                      nsHtml5TreeBuilder::MGLYPH_OR_MALIGNMARK);
   ELT_MATH = new nsHtml5ElementName(
-    nsHtml5Atoms::math, nsHtml5Atoms::math, NS_HTML5TREE_BUILDER_MATH);
+    nsHtml5Atoms::math, nsHtml5Atoms::math, nsHtml5TreeBuilder::MATH);
   ELT_MPATH = new nsHtml5ElementName(
-    nsHtml5Atoms::mpath, nsHtml5Atoms::mpath, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::mpath, nsHtml5Atoms::mpath, nsHtml5TreeBuilder::OTHER);
   ELT_PATH = new nsHtml5ElementName(
-    nsHtml5Atoms::path, nsHtml5Atoms::path, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_TH = new nsHtml5ElementName(
-    nsHtml5Atoms::th,
-    nsHtml5Atoms::th,
-    NS_HTML5TREE_BUILDER_TD_OR_TH | NS_HTML5ELEMENT_NAME_SPECIAL |
-      NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
-  ELT_SWITCH = new nsHtml5ElementName(nsHtml5Atoms::switch_, nsHtml5Atoms::switch_, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::path, nsHtml5Atoms::path, nsHtml5TreeBuilder::OTHER);
+  ELT_TH = new nsHtml5ElementName(nsHtml5Atoms::th,
+                                  nsHtml5Atoms::th,
+                                  nsHtml5TreeBuilder::TD_OR_TH | SPECIAL |
+                                    SCOPING | OPTIONAL_END_TAG);
+  ELT_SWITCH = new nsHtml5ElementName(
+    nsHtml5Atoms::switch_, nsHtml5Atoms::switch_, nsHtml5TreeBuilder::OTHER);
   ELT_TEXTPATH = new nsHtml5ElementName(
-    nsHtml5Atoms::textpath, nsHtml5Atoms::textPath, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_LI = new nsHtml5ElementName(nsHtml5Atoms::li,
-                                  nsHtml5Atoms::li,
-                                  NS_HTML5TREE_BUILDER_LI |
-                                    NS_HTML5ELEMENT_NAME_SPECIAL |
-                                    NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+    nsHtml5Atoms::textpath, nsHtml5Atoms::textPath, nsHtml5TreeBuilder::OTHER);
+  ELT_LI =
+    new nsHtml5ElementName(nsHtml5Atoms::li,
+                           nsHtml5Atoms::li,
+                           nsHtml5TreeBuilder::LI | SPECIAL | OPTIONAL_END_TAG);
   ELT_MI = new nsHtml5ElementName(nsHtml5Atoms::mi,
                                   nsHtml5Atoms::mi,
-                                  NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT |
-                                    NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
-  ELT_LINK =
-    new nsHtml5ElementName(nsHtml5Atoms::link,
-                           nsHtml5Atoms::link,
-                           NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND |
-                             NS_HTML5ELEMENT_NAME_SPECIAL);
+                                  nsHtml5TreeBuilder::MI_MO_MN_MS_MTEXT |
+                                    SCOPING_AS_MATHML);
+  ELT_LINK = new nsHtml5ElementName(
+    nsHtml5Atoms::link,
+    nsHtml5Atoms::link,
+    nsHtml5TreeBuilder::LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
   ELT_MARK = new nsHtml5ElementName(
-    nsHtml5Atoms::mark, nsHtml5Atoms::mark, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::mark, nsHtml5Atoms::mark, nsHtml5TreeBuilder::OTHER);
   ELT_MALIGNMARK =
     new nsHtml5ElementName(nsHtml5Atoms::malignmark,
                            nsHtml5Atoms::malignmark,
-                           NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK);
+                           nsHtml5TreeBuilder::MGLYPH_OR_MALIGNMARK);
   ELT_MASK = new nsHtml5ElementName(
-    nsHtml5Atoms::mask, nsHtml5Atoms::mask, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_TRACK =
-    new nsHtml5ElementName(nsHtml5Atoms::track,
-                           nsHtml5Atoms::track,
-                           NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE_OR_TRACK |
-                             NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5Atoms::mask, nsHtml5Atoms::mask, nsHtml5TreeBuilder::OTHER);
+  ELT_TRACK = new nsHtml5ElementName(
+    nsHtml5Atoms::track,
+    nsHtml5Atoms::track,
+    nsHtml5TreeBuilder::PARAM_OR_SOURCE_OR_TRACK | SPECIAL);
   ELT_DL = new nsHtml5ElementName(nsHtml5Atoms::dl,
                                   nsHtml5Atoms::dl,
-                                  NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL |
-                                    NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_HTML = new nsHtml5ElementName(
-    nsHtml5Atoms::html,
-    nsHtml5Atoms::html,
-    NS_HTML5TREE_BUILDER_HTML | NS_HTML5ELEMENT_NAME_SPECIAL |
-      NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+                                  nsHtml5TreeBuilder::UL_OR_OL_OR_DL | SPECIAL);
+  ELT_HTML = new nsHtml5ElementName(nsHtml5Atoms::html,
+                                    nsHtml5Atoms::html,
+                                    nsHtml5TreeBuilder::HTML | SPECIAL |
+                                      SCOPING | OPTIONAL_END_TAG);
   ELT_OL = new nsHtml5ElementName(nsHtml5Atoms::ol,
                                   nsHtml5Atoms::ol,
-                                  NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL |
-                                    NS_HTML5ELEMENT_NAME_SPECIAL);
+                                  nsHtml5TreeBuilder::UL_OR_OL_OR_DL | SPECIAL);
   ELT_LABEL = new nsHtml5ElementName(
-    nsHtml5Atoms::label, nsHtml5Atoms::label, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::label, nsHtml5Atoms::label, nsHtml5TreeBuilder::OTHER);
   ELT_UL = new nsHtml5ElementName(nsHtml5Atoms::ul,
                                   nsHtml5Atoms::ul,
-                                  NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL |
-                                    NS_HTML5ELEMENT_NAME_SPECIAL);
+                                  nsHtml5TreeBuilder::UL_OR_OL_OR_DL | 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_SYMBOL = new nsHtml5ElementName(nsHtml5Atoms::symbol, nsHtml5Atoms::symbol, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5TreeBuilder::
+      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+  ELT_SYMBOL = new nsHtml5ElementName(
+    nsHtml5Atoms::symbol, nsHtml5Atoms::symbol, nsHtml5TreeBuilder::OTHER);
   ELT_ALTGLYPHITEM = new nsHtml5ElementName(nsHtml5Atoms::altglyphitem,
                                             nsHtml5Atoms::altGlyphItem,
-                                            NS_HTML5TREE_BUILDER_OTHER);
+                                            nsHtml5TreeBuilder::OTHER);
   ELT_ANIMATETRANSFORM = new nsHtml5ElementName(nsHtml5Atoms::animatetransform,
                                                 nsHtml5Atoms::animateTransform,
-                                                NS_HTML5TREE_BUILDER_OTHER);
-  ELT_ACRONYM = new nsHtml5ElementName(nsHtml5Atoms::acronym, nsHtml5Atoms::acronym, NS_HTML5TREE_BUILDER_OTHER);
+                                                nsHtml5TreeBuilder::OTHER);
+  ELT_ACRONYM = new nsHtml5ElementName(
+    nsHtml5Atoms::acronym, nsHtml5Atoms::acronym, nsHtml5TreeBuilder::OTHER);
   ELT_EM = new nsHtml5ElementName(
     nsHtml5Atoms::em,
     nsHtml5Atoms::em,
-    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_FORM = new nsHtml5ElementName(nsHtml5Atoms::form,
-                                    nsHtml5Atoms::form,
-                                    NS_HTML5TREE_BUILDER_FORM |
-                                      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::
+      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
+  ELT_FORM = new nsHtml5ElementName(
+    nsHtml5Atoms::form, nsHtml5Atoms::form, nsHtml5TreeBuilder::FORM | SPECIAL);
   ELT_MENUITEM = new nsHtml5ElementName(nsHtml5Atoms::menuitem,
                                         nsHtml5Atoms::menuitem,
-                                        NS_HTML5TREE_BUILDER_MENUITEM);
-  ELT_PARAM =
-    new nsHtml5ElementName(nsHtml5Atoms::param,
-                           nsHtml5Atoms::param,
-                           NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE_OR_TRACK |
-                             NS_HTML5ELEMENT_NAME_SPECIAL);
+                                        nsHtml5TreeBuilder::MENUITEM);
+  ELT_PARAM = new nsHtml5ElementName(
+    nsHtml5Atoms::param,
+    nsHtml5Atoms::param,
+    nsHtml5TreeBuilder::PARAM_OR_SOURCE_OR_TRACK | SPECIAL);
   ELT_ANIMATEMOTION = new nsHtml5ElementName(nsHtml5Atoms::animatemotion,
                                              nsHtml5Atoms::animateMotion,
-                                             NS_HTML5TREE_BUILDER_OTHER);
+                                             nsHtml5TreeBuilder::OTHER);
   ELT_BUTTON = new nsHtml5ElementName(nsHtml5Atoms::button,
                                       nsHtml5Atoms::button,
-                                      NS_HTML5TREE_BUILDER_BUTTON |
-                                        NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_CAPTION = new nsHtml5ElementName(nsHtml5Atoms::caption, nsHtml5Atoms::caption, NS_HTML5TREE_BUILDER_CAPTION | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_SCOPING);
+                                      nsHtml5TreeBuilder::BUTTON | SPECIAL);
+  ELT_CAPTION =
+    new nsHtml5ElementName(nsHtml5Atoms::caption,
+                           nsHtml5Atoms::caption,
+                           nsHtml5TreeBuilder::CAPTION | SPECIAL | SCOPING);
   ELT_FIGCAPTION = new nsHtml5ElementName(
     nsHtml5Atoms::figcaption,
     nsHtml5Atoms::figcaption,
-    NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
   ELT_MN = new nsHtml5ElementName(nsHtml5Atoms::mn,
                                   nsHtml5Atoms::mn,
-                                  NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT |
-                                    NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
+                                  nsHtml5TreeBuilder::MI_MO_MN_MS_MTEXT |
+                                    SCOPING_AS_MATHML);
   ELT_KEYGEN = new nsHtml5ElementName(
-    nsHtml5Atoms::keygen, nsHtml5Atoms::keygen, NS_HTML5TREE_BUILDER_KEYGEN);
+    nsHtml5Atoms::keygen, nsHtml5Atoms::keygen, nsHtml5TreeBuilder::KEYGEN);
   ELT_MAIN = new nsHtml5ElementName(
     nsHtml5Atoms::main,
     nsHtml5Atoms::main,
-    NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_OPTION = new nsHtml5ElementName(nsHtml5Atoms::option,
-                                      nsHtml5Atoms::option,
-                                      NS_HTML5TREE_BUILDER_OPTION |
-                                        NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
-  ELT_POLYGON = new nsHtml5ElementName(nsHtml5Atoms::polygon, nsHtml5Atoms::polygon, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_PATTERN = new nsHtml5ElementName(nsHtml5Atoms::pattern, nsHtml5Atoms::pattern, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
+  ELT_OPTION =
+    new nsHtml5ElementName(nsHtml5Atoms::option,
+                           nsHtml5Atoms::option,
+                           nsHtml5TreeBuilder::OPTION | OPTIONAL_END_TAG);
+  ELT_POLYGON = new nsHtml5ElementName(
+    nsHtml5Atoms::polygon, nsHtml5Atoms::polygon, nsHtml5TreeBuilder::OTHER);
+  ELT_PATTERN = new nsHtml5ElementName(
+    nsHtml5Atoms::pattern, nsHtml5Atoms::pattern, nsHtml5TreeBuilder::OTHER);
   ELT_SPAN = new nsHtml5ElementName(
     nsHtml5Atoms::span,
     nsHtml5Atoms::span,
-    NS_HTML5TREE_BUILDER_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
-  ELT_SECTION = new nsHtml5ElementName(nsHtml5Atoms::section, nsHtml5Atoms::section, NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
+  ELT_SECTION = new nsHtml5ElementName(
+    nsHtml5Atoms::section,
+    nsHtml5Atoms::section,
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
   ELT_TSPAN = new nsHtml5ElementName(
-    nsHtml5Atoms::tspan, nsHtml5Atoms::tspan, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::tspan, nsHtml5Atoms::tspan, nsHtml5TreeBuilder::OTHER);
   ELT_AUDIO = new nsHtml5ElementName(
-    nsHtml5Atoms::audio, nsHtml5Atoms::audio, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::audio, nsHtml5Atoms::audio, nsHtml5TreeBuilder::OTHER);
   ELT_MO = new nsHtml5ElementName(nsHtml5Atoms::mo,
                                   nsHtml5Atoms::mo,
-                                  NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT |
-                                    NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
+                                  nsHtml5TreeBuilder::MI_MO_MN_MS_MTEXT |
+                                    SCOPING_AS_MATHML);
   ELT_VIDEO = new nsHtml5ElementName(
-    nsHtml5Atoms::video, nsHtml5Atoms::video, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_COLGROUP = new nsHtml5ElementName(nsHtml5Atoms::colgroup, nsHtml5Atoms::colgroup, NS_HTML5TREE_BUILDER_COLGROUP | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+    nsHtml5Atoms::video, nsHtml5Atoms::video, nsHtml5TreeBuilder::OTHER);
+  ELT_COLGROUP = new nsHtml5ElementName(nsHtml5Atoms::colgroup,
+                                        nsHtml5Atoms::colgroup,
+                                        nsHtml5TreeBuilder::COLGROUP | SPECIAL |
+                                          OPTIONAL_END_TAG);
   ELT_FEDISPLACEMENTMAP =
     new nsHtml5ElementName(nsHtml5Atoms::fedisplacementmap,
                            nsHtml5Atoms::feDisplacementMap,
-                           NS_HTML5TREE_BUILDER_OTHER);
+                           nsHtml5TreeBuilder::OTHER);
   ELT_HGROUP = new nsHtml5ElementName(
     nsHtml5Atoms::hgroup,
     nsHtml5Atoms::hgroup,
-    NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_RP = new nsHtml5ElementName(nsHtml5Atoms::rp,
-                                  nsHtml5Atoms::rp,
-                                  NS_HTML5TREE_BUILDER_RT_OR_RP |
-                                    NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
-  ELT_OPTGROUP = new nsHtml5ElementName(
-    nsHtml5Atoms::optgroup,
-    nsHtml5Atoms::optgroup,
-    NS_HTML5TREE_BUILDER_OPTGROUP | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
+  ELT_RP =
+    new nsHtml5ElementName(nsHtml5Atoms::rp,
+                           nsHtml5Atoms::rp,
+                           nsHtml5TreeBuilder::RT_OR_RP | OPTIONAL_END_TAG);
+  ELT_OPTGROUP =
+    new nsHtml5ElementName(nsHtml5Atoms::optgroup,
+                           nsHtml5Atoms::optgroup,
+                           nsHtml5TreeBuilder::OPTGROUP | OPTIONAL_END_TAG);
   ELT_SAMP = new nsHtml5ElementName(
-    nsHtml5Atoms::samp, nsHtml5Atoms::samp, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::samp, nsHtml5Atoms::samp, nsHtml5TreeBuilder::OTHER);
   ELT_STOP = new nsHtml5ElementName(
-    nsHtml5Atoms::stop, nsHtml5Atoms::stop, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_BR = new nsHtml5ElementName(nsHtml5Atoms::br,
-                                  nsHtml5Atoms::br,
-                                  NS_HTML5TREE_BUILDER_BR |
-                                    NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5Atoms::stop, nsHtml5Atoms::stop, nsHtml5TreeBuilder::OTHER);
+  ELT_BR = new nsHtml5ElementName(
+    nsHtml5Atoms::br, nsHtml5Atoms::br, nsHtml5TreeBuilder::BR | SPECIAL);
   ELT_ABBR = new nsHtml5ElementName(
-    nsHtml5Atoms::abbr, nsHtml5Atoms::abbr, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::abbr, nsHtml5Atoms::abbr, nsHtml5TreeBuilder::OTHER);
   ELT_ANIMATECOLOR = new nsHtml5ElementName(nsHtml5Atoms::animatecolor,
                                             nsHtml5Atoms::animateColor,
-                                            NS_HTML5TREE_BUILDER_OTHER);
+                                            nsHtml5TreeBuilder::OTHER);
   ELT_CENTER = new nsHtml5ElementName(
     nsHtml5Atoms::center,
     nsHtml5Atoms::center,
-    NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_HR = new nsHtml5ElementName(nsHtml5Atoms::hr,
-                                  nsHtml5Atoms::hr,
-                                  NS_HTML5TREE_BUILDER_HR |
-                                    NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
+  ELT_HR = new nsHtml5ElementName(
+    nsHtml5Atoms::hr, nsHtml5Atoms::hr, nsHtml5TreeBuilder::HR | SPECIAL);
   ELT_FEFUNCR = new nsHtml5ElementName(
-    nsHtml5Atoms::fefuncr, nsHtml5Atoms::feFuncR, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::fefuncr, nsHtml5Atoms::feFuncR, nsHtml5TreeBuilder::OTHER);
   ELT_FECOMPONENTTRANSFER =
     new nsHtml5ElementName(nsHtml5Atoms::fecomponenttransfer,
                            nsHtml5Atoms::feComponentTransfer,
-                           NS_HTML5TREE_BUILDER_OTHER);
+                           nsHtml5TreeBuilder::OTHER);
   ELT_FILTER = new nsHtml5ElementName(
-    nsHtml5Atoms::filter, nsHtml5Atoms::filter, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::filter, nsHtml5Atoms::filter, nsHtml5TreeBuilder::OTHER);
   ELT_FOOTER = new nsHtml5ElementName(
     nsHtml5Atoms::footer,
     nsHtml5Atoms::footer,
-    NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
   ELT_FEGAUSSIANBLUR = new nsHtml5ElementName(nsHtml5Atoms::fegaussianblur,
                                               nsHtml5Atoms::feGaussianBlur,
-                                              NS_HTML5TREE_BUILDER_OTHER);
+                                              nsHtml5TreeBuilder::OTHER);
   ELT_HEADER = new nsHtml5ElementName(
     nsHtml5Atoms::header,
     nsHtml5Atoms::header,
-    NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
   ELT_MARKER = new nsHtml5ElementName(
-    nsHtml5Atoms::marker, nsHtml5Atoms::marker, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::marker, nsHtml5Atoms::marker, nsHtml5TreeBuilder::OTHER);
   ELT_METER = new nsHtml5ElementName(
-    nsHtml5Atoms::meter, nsHtml5Atoms::meter, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::meter, nsHtml5Atoms::meter, nsHtml5TreeBuilder::OTHER);
   ELT_NOBR = new nsHtml5ElementName(
-    nsHtml5Atoms::nobr, nsHtml5Atoms::nobr, NS_HTML5TREE_BUILDER_NOBR);
+    nsHtml5Atoms::nobr, nsHtml5Atoms::nobr, nsHtml5TreeBuilder::NOBR);
   ELT_TR = new nsHtml5ElementName(nsHtml5Atoms::tr,
                                   nsHtml5Atoms::tr,
-                                  NS_HTML5TREE_BUILDER_TR |
-                                    NS_HTML5ELEMENT_NAME_SPECIAL |
-                                    NS_HTML5ELEMENT_NAME_FOSTER_PARENTING |
-                                    NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+                                  nsHtml5TreeBuilder::TR | SPECIAL |
+                                    FOSTER_PARENTING | OPTIONAL_END_TAG);
   ELT_ADDRESS = new nsHtml5ElementName(
     nsHtml5Atoms::address,
     nsHtml5Atoms::address,
-    NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
   ELT_CANVAS = new nsHtml5ElementName(
-    nsHtml5Atoms::canvas, nsHtml5Atoms::canvas, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::canvas, nsHtml5Atoms::canvas, nsHtml5TreeBuilder::OTHER);
   ELT_DEFS = new nsHtml5ElementName(
-    nsHtml5Atoms::defs, nsHtml5Atoms::defs, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::defs, nsHtml5Atoms::defs, nsHtml5TreeBuilder::OTHER);
   ELT_DETAILS = new nsHtml5ElementName(
     nsHtml5Atoms::details,
     nsHtml5Atoms::details,
-    NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
   ELT_MS = new nsHtml5ElementName(nsHtml5Atoms::ms,
                                   nsHtml5Atoms::ms,
-                                  NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT |
-                                    NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
+                                  nsHtml5TreeBuilder::MI_MO_MN_MS_MTEXT |
+                                    SCOPING_AS_MATHML);
   ELT_NOFRAMES = new nsHtml5ElementName(nsHtml5Atoms::noframes,
                                         nsHtml5Atoms::noframes,
-                                        NS_HTML5TREE_BUILDER_NOFRAMES |
-                                          NS_HTML5ELEMENT_NAME_SPECIAL);
+                                        nsHtml5TreeBuilder::NOFRAMES | SPECIAL);
   ELT_PROGRESS = new nsHtml5ElementName(
-    nsHtml5Atoms::progress, nsHtml5Atoms::progress, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::progress, nsHtml5Atoms::progress, nsHtml5TreeBuilder::OTHER);
   ELT_DT = new nsHtml5ElementName(nsHtml5Atoms::dt,
                                   nsHtml5Atoms::dt,
-                                  NS_HTML5TREE_BUILDER_DD_OR_DT |
-                                    NS_HTML5ELEMENT_NAME_SPECIAL |
-                                    NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+                                  nsHtml5TreeBuilder::DD_OR_DT | SPECIAL |
+                                    OPTIONAL_END_TAG);
   ELT_APPLET = new nsHtml5ElementName(nsHtml5Atoms::applet,
                                       nsHtml5Atoms::applet,
-                                      NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET |
-                                        NS_HTML5ELEMENT_NAME_SPECIAL |
-                                        NS_HTML5ELEMENT_NAME_SCOPING);
-  ELT_BASEFONT =
-    new nsHtml5ElementName(nsHtml5Atoms::basefont,
-                           nsHtml5Atoms::basefont,
-                           NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND |
-                             NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_FOREIGNOBJECT =
-    new nsHtml5ElementName(nsHtml5Atoms::foreignobject,
-                           nsHtml5Atoms::foreignObject,
-                           NS_HTML5TREE_BUILDER_FOREIGNOBJECT_OR_DESC |
-                             NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG);
-  ELT_FIELDSET = new nsHtml5ElementName(nsHtml5Atoms::fieldset, nsHtml5Atoms::fieldset, NS_HTML5TREE_BUILDER_FIELDSET | NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_FRAMESET = new nsHtml5ElementName(nsHtml5Atoms::frameset, nsHtml5Atoms::frameset, NS_HTML5TREE_BUILDER_FRAMESET | NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_FEOFFSET = new nsHtml5ElementName(nsHtml5Atoms::feoffset, nsHtml5Atoms::feOffset, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_FESPOTLIGHT = new nsHtml5ElementName(nsHtml5Atoms::fespotlight, nsHtml5Atoms::feSpotLight, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_FEPOINTLIGHT = new nsHtml5ElementName(nsHtml5Atoms::fepointlight, nsHtml5Atoms::fePointLight, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_FEDISTANTLIGHT = new nsHtml5ElementName(nsHtml5Atoms::fedistantlight, nsHtml5Atoms::feDistantLight, NS_HTML5TREE_BUILDER_OTHER);
+                                      nsHtml5TreeBuilder::MARQUEE_OR_APPLET |
+                                        SPECIAL | SCOPING);
+  ELT_BASEFONT = new nsHtml5ElementName(
+    nsHtml5Atoms::basefont,
+    nsHtml5Atoms::basefont,
+    nsHtml5TreeBuilder::LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
+  ELT_FOREIGNOBJECT = new nsHtml5ElementName(
+    nsHtml5Atoms::foreignobject,
+    nsHtml5Atoms::foreignObject,
+    nsHtml5TreeBuilder::FOREIGNOBJECT_OR_DESC | SCOPING_AS_SVG);
+  ELT_FIELDSET = new nsHtml5ElementName(nsHtml5Atoms::fieldset,
+                                        nsHtml5Atoms::fieldset,
+                                        nsHtml5TreeBuilder::FIELDSET | SPECIAL);
+  ELT_FRAMESET = new nsHtml5ElementName(nsHtml5Atoms::frameset,
+                                        nsHtml5Atoms::frameset,
+                                        nsHtml5TreeBuilder::FRAMESET | SPECIAL);
+  ELT_FEOFFSET = new nsHtml5ElementName(
+    nsHtml5Atoms::feoffset, nsHtml5Atoms::feOffset, nsHtml5TreeBuilder::OTHER);
+  ELT_FESPOTLIGHT = new nsHtml5ElementName(nsHtml5Atoms::fespotlight,
+                                           nsHtml5Atoms::feSpotLight,
+                                           nsHtml5TreeBuilder::OTHER);
+  ELT_FEPOINTLIGHT = new nsHtml5ElementName(nsHtml5Atoms::fepointlight,
+                                            nsHtml5Atoms::fePointLight,
+                                            nsHtml5TreeBuilder::OTHER);
+  ELT_FEDISTANTLIGHT = new nsHtml5ElementName(nsHtml5Atoms::fedistantlight,
+                                              nsHtml5Atoms::feDistantLight,
+                                              nsHtml5TreeBuilder::OTHER);
   ELT_FONT = new nsHtml5ElementName(
-    nsHtml5Atoms::font, nsHtml5Atoms::font, NS_HTML5TREE_BUILDER_FONT);
+    nsHtml5Atoms::font, nsHtml5Atoms::font, nsHtml5TreeBuilder::FONT);
   ELT_INPUT = new nsHtml5ElementName(nsHtml5Atoms::input,
                                      nsHtml5Atoms::input,
-                                     NS_HTML5TREE_BUILDER_INPUT |
-                                       NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_LINEARGRADIENT = new nsHtml5ElementName(nsHtml5Atoms::lineargradient, nsHtml5Atoms::linearGradient, NS_HTML5TREE_BUILDER_OTHER);
+                                     nsHtml5TreeBuilder::INPUT | SPECIAL);
+  ELT_LINEARGRADIENT = new nsHtml5ElementName(nsHtml5Atoms::lineargradient,
+                                              nsHtml5Atoms::linearGradient,
+                                              nsHtml5TreeBuilder::OTHER);
   ELT_MTEXT = new nsHtml5ElementName(nsHtml5Atoms::mtext,
                                      nsHtml5Atoms::mtext,
-                                     NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT |
-                                       NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML);
+                                     nsHtml5TreeBuilder::MI_MO_MN_MS_MTEXT |
+                                       SCOPING_AS_MATHML);
   ELT_NOSCRIPT = new nsHtml5ElementName(nsHtml5Atoms::noscript,
                                         nsHtml5Atoms::noscript,
-                                        NS_HTML5TREE_BUILDER_NOSCRIPT |
-                                          NS_HTML5ELEMENT_NAME_SPECIAL);
-  ELT_RT = new nsHtml5ElementName(nsHtml5Atoms::rt,
-                                  nsHtml5Atoms::rt,
-                                  NS_HTML5TREE_BUILDER_RT_OR_RP |
-                                    NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
-  ELT_OBJECT = new nsHtml5ElementName(nsHtml5Atoms::object,
-                                      nsHtml5Atoms::object,
-                                      NS_HTML5TREE_BUILDER_OBJECT |
-                                        NS_HTML5ELEMENT_NAME_SPECIAL |
-                                        NS_HTML5ELEMENT_NAME_SCOPING);
+                                        nsHtml5TreeBuilder::NOSCRIPT | SPECIAL);
+  ELT_RT =
+    new nsHtml5ElementName(nsHtml5Atoms::rt,
+                           nsHtml5Atoms::rt,
+                           nsHtml5TreeBuilder::RT_OR_RP | OPTIONAL_END_TAG);
+  ELT_OBJECT =
+    new nsHtml5ElementName(nsHtml5Atoms::object,
+                           nsHtml5Atoms::object,
+                           nsHtml5TreeBuilder::OBJECT | SPECIAL | SCOPING);
   ELT_OUTPUT = new nsHtml5ElementName(
-    nsHtml5Atoms::output, nsHtml5Atoms::output, NS_HTML5TREE_BUILDER_OUTPUT);
-  ELT_PLAINTEXT = new nsHtml5ElementName(nsHtml5Atoms::plaintext,
-                                         nsHtml5Atoms::plaintext,
-                                         NS_HTML5TREE_BUILDER_PLAINTEXT |
-                                           NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5Atoms::output, nsHtml5Atoms::output, nsHtml5TreeBuilder::OUTPUT);
+  ELT_PLAINTEXT =
+    new nsHtml5ElementName(nsHtml5Atoms::plaintext,
+                           nsHtml5Atoms::plaintext,
+                           nsHtml5TreeBuilder::PLAINTEXT | SPECIAL);
   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);
+    nsHtml5TreeBuilder::
+      B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U);
   ELT_RECT = new nsHtml5ElementName(
-    nsHtml5Atoms::rect, nsHtml5Atoms::rect, NS_HTML5TREE_BUILDER_OTHER);
-  ELT_RADIALGRADIENT = new nsHtml5ElementName(nsHtml5Atoms::radialgradient, nsHtml5Atoms::radialGradient, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::rect, nsHtml5Atoms::rect, nsHtml5TreeBuilder::OTHER);
+  ELT_RADIALGRADIENT = new nsHtml5ElementName(nsHtml5Atoms::radialgradient,
+                                              nsHtml5Atoms::radialGradient,
+                                              nsHtml5TreeBuilder::OTHER);
   ELT_SELECT = new nsHtml5ElementName(nsHtml5Atoms::select,
                                       nsHtml5Atoms::select,
-                                      NS_HTML5TREE_BUILDER_SELECT |
-                                        NS_HTML5ELEMENT_NAME_SPECIAL);
+                                      nsHtml5TreeBuilder::SELECT | SPECIAL);
   ELT_SCRIPT = new nsHtml5ElementName(nsHtml5Atoms::script,
                                       nsHtml5Atoms::script,
-                                      NS_HTML5TREE_BUILDER_SCRIPT |
-                                        NS_HTML5ELEMENT_NAME_SPECIAL);
-  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 |
-      NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+                                      nsHtml5TreeBuilder::SCRIPT | SPECIAL);
+  ELT_TFOOT =
+    new nsHtml5ElementName(nsHtml5Atoms::tfoot,
+                           nsHtml5Atoms::tfoot,
+                           nsHtml5TreeBuilder::TBODY_OR_THEAD_OR_TFOOT |
+                             SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
   ELT_TEXT = new nsHtml5ElementName(
-    nsHtml5Atoms::text, nsHtml5Atoms::text, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::text, nsHtml5Atoms::text, nsHtml5TreeBuilder::OTHER);
   ELT_MENU = new nsHtml5ElementName(
     nsHtml5Atoms::menu,
     nsHtml5Atoms::menu,
-    NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
+    nsHtml5TreeBuilder::DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU | SPECIAL);
   ELT_FEDROPSHADOW = new nsHtml5ElementName(nsHtml5Atoms::fedropshadow,
                                             nsHtml5Atoms::feDropShadow,
-                                            NS_HTML5TREE_BUILDER_OTHER);
+                                            nsHtml5TreeBuilder::OTHER);
   ELT_VIEW = new nsHtml5ElementName(
-    nsHtml5Atoms::view, nsHtml5Atoms::view, NS_HTML5TREE_BUILDER_OTHER);
+    nsHtml5Atoms::view, nsHtml5Atoms::view, nsHtml5TreeBuilder::OTHER);
   ELT_FECOLORMATRIX = new nsHtml5ElementName(nsHtml5Atoms::fecolormatrix,
                                              nsHtml5Atoms::feColorMatrix,
-                                             NS_HTML5TREE_BUILDER_OTHER);
-  ELT_FECONVOLVEMATRIX = new nsHtml5ElementName(nsHtml5Atoms::feconvolvematrix, nsHtml5Atoms::feConvolveMatrix, NS_HTML5TREE_BUILDER_OTHER);
+                                             nsHtml5TreeBuilder::OTHER);
+  ELT_FECONVOLVEMATRIX = new nsHtml5ElementName(nsHtml5Atoms::feconvolvematrix,
+                                                nsHtml5Atoms::feConvolveMatrix,
+                                                nsHtml5TreeBuilder::OTHER);
   ELT_BODY = new nsHtml5ElementName(nsHtml5Atoms::body,
                                     nsHtml5Atoms::body,
-                                    NS_HTML5TREE_BUILDER_BODY |
-                                      NS_HTML5ELEMENT_NAME_SPECIAL |
-                                      NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+                                    nsHtml5TreeBuilder::BODY | SPECIAL |
+                                      OPTIONAL_END_TAG);
   ELT_FEMORPHOLOGY = new nsHtml5ElementName(nsHtml5Atoms::femorphology,
                                             nsHtml5Atoms::feMorphology,
-                                            NS_HTML5TREE_BUILDER_OTHER);
+                                            nsHtml5TreeBuilder::OTHER);
   ELT_RUBY = new nsHtml5ElementName(
     nsHtml5Atoms::ruby,
     nsHtml5Atoms::ruby,
-    NS_HTML5TREE_BUILDER_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
+    nsHtml5TreeBuilder::RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
   ELT_SUMMARY = new nsHtml5ElementName(
     nsHtml5Atoms::summary,
     nsHtml5Atoms::summary,
-    NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
-      NS_HTML5ELEMENT_NAME_SPECIAL);
-  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 |
-      NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
+    nsHtml5TreeBuilder::
+        ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY |
+      SPECIAL);
+  ELT_TBODY =
+    new nsHtml5ElementName(nsHtml5Atoms::tbody,
+                           nsHtml5Atoms::tbody,
+                           nsHtml5TreeBuilder::TBODY_OR_THEAD_OR_TFOOT |
+                             SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
   ELEMENT_NAMES = new nsHtml5ElementName*[204];
   ELEMENT_NAMES[0] = ELT_BIG;
   ELEMENT_NAMES[1] = ELT_BDO;
   ELEMENT_NAMES[2] = ELT_COL;
   ELEMENT_NAMES[3] = ELT_DEL;
   ELEMENT_NAMES[4] = ELT_DFN;
   ELEMENT_NAMES[5] = ELT_DIR;
   ELEMENT_NAMES[6] = ELT_DIV;
--- a/parser/html/nsHtml5ElementName.h
+++ b/parser/html/nsHtml5ElementName.h
@@ -37,48 +37,89 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Atoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
+#include "nsHtml5Portability.h"
 
 class nsHtml5StreamParser;
 
+class nsHtml5AttributeName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
-class nsHtml5AttributeName;
 class nsHtml5UTF16Buffer;
 class nsHtml5StateSnapshot;
 class nsHtml5Portability;
 
 
 class nsHtml5ElementName
 {
+public:
+  static const int32_t GROUP_MASK = 127;
+
+  static const int32_t NOT_INTERNED = (1 << 30);
+
+  static const int32_t SPECIAL = (1 << 29);
+
+  static const int32_t FOSTER_PARENTING = (1 << 28);
+
+  static const int32_t SCOPING = (1 << 27);
+
+  static const int32_t SCOPING_AS_SVG = (1 << 26);
+
+  static const int32_t SCOPING_AS_MATHML = (1 << 25);
+
+  static const int32_t HTML_INTEGRATION_POINT = (1 << 24);
+
+  static const int32_t OPTIONAL_END_TAG = (1 << 23);
+
 private:
   nsIAtom* name;
   nsIAtom* camelCaseName;
 
 public:
   int32_t flags;
   inline nsIAtom* getName() { return name; }
 
   inline nsIAtom* getCamelCaseName() { return camelCaseName; }
 
   inline int32_t getFlags() { return flags; }
 
-  int32_t getGroup();
-  bool isInterned();
-  static nsHtml5ElementName* elementNameByBuffer(char16_t* buf,
-                                                 int32_t offset,
-                                                 int32_t length,
-                                                 nsHtml5AtomTable* interner);
+  inline int32_t getGroup() { return flags & nsHtml5ElementName::GROUP_MASK; }
+
+  inline bool isInterned()
+  {
+    return !(flags & nsHtml5ElementName::NOT_INTERNED);
+  }
+
+  inline static nsHtml5ElementName* elementNameByBuffer(
+    char16_t* buf,
+    int32_t offset,
+    int32_t length,
+    nsHtml5AtomTable* interner)
+  {
+    uint32_t hash = nsHtml5ElementName::bufToHash(buf, length);
+    int32_t index = nsHtml5ElementName::ELEMENT_HASHES.binarySearch(hash);
+    if (index < 0) {
+      return nullptr;
+    } else {
+      nsHtml5ElementName* elementName =
+        nsHtml5ElementName::ELEMENT_NAMES[index];
+      nsIAtom* name = elementName->name;
+      if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) {
+        return nullptr;
+      }
+      return elementName;
+    }
+  }
 
 private:
   inline static uint32_t bufToHash(char16_t* buf, int32_t length)
   {
     uint32_t len = length;
     uint32_t first = buf[0];
     first <<= 19;
     uint32_t second = 1 << 23;
@@ -105,17 +146,23 @@ private:
     }
     return len + first + second + third + fourth + fifth;
     }
 
     nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, int32_t flags);
   public:
     nsHtml5ElementName();
     ~nsHtml5ElementName();
-    void setNameForNonInterned(nsIAtom* name);
+    inline void setNameForNonInterned(nsIAtom* name)
+    {
+      this->name = name;
+      this->camelCaseName = name;
+      MOZ_ASSERT(this->flags == nsHtml5ElementName::NOT_INTERNED);
+    }
+
     static nsHtml5ElementName* ELT_ANNOTATION_XML;
     static nsHtml5ElementName* ELT_ISINDEX;
     static nsHtml5ElementName* ELT_BIG;
     static nsHtml5ElementName* ELT_BDO;
     static nsHtml5ElementName* ELT_COL;
     static nsHtml5ElementName* ELT_DEL;
     static nsHtml5ElementName* ELT_DFN;
     static nsHtml5ElementName* ELT_DIR;
@@ -319,21 +366,10 @@ private:
   private:
     static nsHtml5ElementName** ELEMENT_NAMES;
     static staticJArray<int32_t,int32_t> ELEMENT_HASHES;
   public:
     static void initializeStatics();
     static void releaseStatics();
 };
 
-#define NS_HTML5ELEMENT_NAME_GROUP_MASK 127
-#define NS_HTML5ELEMENT_NAME_NOT_INTERNED (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)
-#define NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG (1 << 23)
-
-
 #endif
 
--- a/parser/html/nsHtml5Highlighter.cpp
+++ b/parser/html/nsHtml5Highlighter.cpp
@@ -43,17 +43,17 @@ char16_t nsHtml5Highlighter::sAttributeV
 
 char16_t nsHtml5Highlighter::sDoctype[] =
   { 'd', 'o', 'c', 't', 'y', 'p', 'e', 0 };
 
 char16_t nsHtml5Highlighter::sPi[] =
   { 'p', 'i', 0 };
 
 nsHtml5Highlighter::nsHtml5Highlighter(nsAHtml5TreeOpSink* aOpSink)
- : mState(NS_HTML5TOKENIZER_DATA)
+ : mState(nsHtml5Tokenizer::DATA)
  , mCStart(INT32_MAX)
  , mPos(0)
  , mLineNumber(1)
  , mInlinesOpen(0)
  , mInCharacters(false)
  , mBuffer(nullptr)
  , mOpSink(aOpSink)
  , mCurrentRun(nullptr)
@@ -114,357 +114,357 @@ nsHtml5Highlighter::Start(const nsAutoSt
   mOpQueue.AppendElement()->Init(eTreeOpStartLayout);
 }
 
 int32_t
 nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
 {
   mPos = aPos;
   switch (mState) {
-    case NS_HTML5TOKENIZER_SCRIPT_DATA:
-    case NS_HTML5TOKENIZER_RAWTEXT:
-    case NS_HTML5TOKENIZER_RCDATA:
-    case NS_HTML5TOKENIZER_DATA:
+    case nsHtml5Tokenizer::SCRIPT_DATA:
+    case nsHtml5Tokenizer::RAWTEXT:
+    case nsHtml5Tokenizer::RCDATA:
+    case nsHtml5Tokenizer::DATA:
       // We can transition on < and on &. Either way, we don't yet know the
       // role of the token, so open a span without class.
-      if (aState == NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE) {
+      if (aState == nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE) {
         StartSpan();
         // Start another span for highlighting the ampersand
         StartSpan();
         mAmpersand = CurrentNode();
       } else {
         EndCharactersAndStartMarkupRun();
       }
       break;
-    case NS_HTML5TOKENIZER_TAG_OPEN:
+    case nsHtml5Tokenizer::TAG_OPEN:
       switch (aState) {
-        case NS_HTML5TOKENIZER_TAG_NAME:
+        case nsHtml5Tokenizer::TAG_NAME:
           StartSpan(sStartTag);
           break;
-        case NS_HTML5TOKENIZER_DATA:
+        case nsHtml5Tokenizer::DATA:
           FinishTag(); // DATA
           break;
-        case NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION:
+        case nsHtml5Tokenizer::PROCESSING_INSTRUCTION:
           AddClass(sPi);
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_TAG_NAME:
+    case nsHtml5Tokenizer::TAG_NAME:
       switch (aState) {
-        case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME:
-          EndSpanOrA(); // NS_HTML5TOKENIZER_TAG_NAME
+        case nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME:
+          EndSpanOrA(); // nsHtml5Tokenizer::TAG_NAME
           break;
-        case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG:
-          EndSpanOrA(); // NS_HTML5TOKENIZER_TAG_NAME
+        case nsHtml5Tokenizer::SELF_CLOSING_START_TAG:
+          EndSpanOrA(); // nsHtml5Tokenizer::TAG_NAME
           StartSpan(); // for highlighting the slash
           mSlash = CurrentNode();
           break;
         default:
           FinishTag();
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME:
+    case nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME:
       switch (aState) {
-        case NS_HTML5TOKENIZER_ATTRIBUTE_NAME:
+        case nsHtml5Tokenizer::ATTRIBUTE_NAME:
           StartSpan(sAttributeName);
           break;
-        case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG:
+        case nsHtml5Tokenizer::SELF_CLOSING_START_TAG:
           StartSpan(); // for highlighting the slash
           mSlash = CurrentNode();
           break;
         default:
           FinishTag();
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_ATTRIBUTE_NAME:
+    case nsHtml5Tokenizer::ATTRIBUTE_NAME:
       switch (aState) {
-        case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME:
-        case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE:
-          EndSpanOrA(); // NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME
+        case nsHtml5Tokenizer::AFTER_ATTRIBUTE_NAME:
+        case nsHtml5Tokenizer::BEFORE_ATTRIBUTE_VALUE:
+          EndSpanOrA(); // nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME
           break;
-        case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG:
-          EndSpanOrA(); // NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME
+        case nsHtml5Tokenizer::SELF_CLOSING_START_TAG:
+          EndSpanOrA(); // nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME
           StartSpan(); // for highlighting the slash
           mSlash = CurrentNode();
           break;
         default:
           FinishTag();
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE:
+    case nsHtml5Tokenizer::BEFORE_ATTRIBUTE_VALUE:
       switch (aState) {
-        case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED:
-        case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED:
+        case nsHtml5Tokenizer::ATTRIBUTE_VALUE_DOUBLE_QUOTED:
+        case nsHtml5Tokenizer::ATTRIBUTE_VALUE_SINGLE_QUOTED:
           FlushCurrent();
           StartA();
           break;
-        case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED:
+        case nsHtml5Tokenizer::ATTRIBUTE_VALUE_UNQUOTED:
           StartA();
           break;
         default:
           FinishTag();
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED:
-    case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED:
+    case nsHtml5Tokenizer::ATTRIBUTE_VALUE_DOUBLE_QUOTED:
+    case nsHtml5Tokenizer::ATTRIBUTE_VALUE_SINGLE_QUOTED:
       switch (aState) {
-        case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED:
+        case nsHtml5Tokenizer::AFTER_ATTRIBUTE_VALUE_QUOTED:
           EndSpanOrA();
           break;
-        case NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE:
+        case nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE:
           StartSpan();
           StartSpan(); // for ampersand itself
           mAmpersand = CurrentNode();
           break;
         default:
           NS_NOTREACHED("Impossible transition.");
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED:
+    case nsHtml5Tokenizer::AFTER_ATTRIBUTE_VALUE_QUOTED:
       switch (aState) {
-        case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME:
+        case nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME:
           break;
-        case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG:
+        case nsHtml5Tokenizer::SELF_CLOSING_START_TAG:
           StartSpan(); // for highlighting the slash
           mSlash = CurrentNode();
           break;
         default:
           FinishTag();
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG:
+    case nsHtml5Tokenizer::SELF_CLOSING_START_TAG:
       EndSpanOrA(); // end the slash highlight
       switch (aState) {
-        case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME:
+        case nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME:
           break;
         default:
           FinishTag();
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED:
+    case nsHtml5Tokenizer::ATTRIBUTE_VALUE_UNQUOTED:
       switch (aState) {
-        case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME:
+        case nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME:
           EndSpanOrA();
           break;
-        case NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE:
+        case nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE:
           StartSpan();
           StartSpan(); // for ampersand itself
           mAmpersand = CurrentNode();
           break;
         default:
           FinishTag();
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME:
+    case nsHtml5Tokenizer::AFTER_ATTRIBUTE_NAME:
       switch (aState) {
-        case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG:
+        case nsHtml5Tokenizer::SELF_CLOSING_START_TAG:
           StartSpan(); // for highlighting the slash
           mSlash = CurrentNode();
           break;
-        case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE:
+        case nsHtml5Tokenizer::BEFORE_ATTRIBUTE_VALUE:
           break;
-        case NS_HTML5TOKENIZER_ATTRIBUTE_NAME:
+        case nsHtml5Tokenizer::ATTRIBUTE_NAME:
           StartSpan(sAttributeName);
           break;
         default:
           FinishTag();
           break;
       }
       break;
       // most comment states are omitted, because they don't matter to
       // highlighting
-    case NS_HTML5TOKENIZER_COMMENT_START:
-    case NS_HTML5TOKENIZER_COMMENT_END:
-    case NS_HTML5TOKENIZER_COMMENT_END_BANG:
-    case NS_HTML5TOKENIZER_COMMENT_START_DASH:
-    case NS_HTML5TOKENIZER_BOGUS_COMMENT:
-    case NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN:
-      if (aState == NS_HTML5TOKENIZER_DATA) {
+    case nsHtml5Tokenizer::COMMENT_START:
+    case nsHtml5Tokenizer::COMMENT_END:
+    case nsHtml5Tokenizer::COMMENT_END_BANG:
+    case nsHtml5Tokenizer::COMMENT_START_DASH:
+    case nsHtml5Tokenizer::BOGUS_COMMENT:
+    case nsHtml5Tokenizer::BOGUS_COMMENT_HYPHEN:
+      if (aState == nsHtml5Tokenizer::DATA) {
         AddClass(sComment);
         FinishTag();
       }
       break;
       // most cdata states are omitted, because they don't matter to
       // highlighting
-    case NS_HTML5TOKENIZER_CDATA_RSQB_RSQB:
-      if (aState == NS_HTML5TOKENIZER_DATA) {
+    case nsHtml5Tokenizer::CDATA_RSQB_RSQB:
+      if (aState == nsHtml5Tokenizer::DATA) {
         AddClass(sCdata);
         FinishTag();
       }
       break;
-    case NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE:
+    case nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE:
       EndSpanOrA(); // the span for the ampersand
       switch (aState) {
-        case NS_HTML5TOKENIZER_CONSUME_NCR:
-        case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP:
+        case nsHtml5Tokenizer::CONSUME_NCR:
+        case nsHtml5Tokenizer::CHARACTER_REFERENCE_HILO_LOOKUP:
           break;
         default:
           // not actually a character reference
           EndSpanOrA();
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP:
-      if (aState == NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL) {
+    case nsHtml5Tokenizer::CHARACTER_REFERENCE_HILO_LOOKUP:
+      if (aState == nsHtml5Tokenizer::CHARACTER_REFERENCE_TAIL) {
         break;
       }
       // not actually a character reference
       EndSpanOrA();
       break;
-    case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL:
+    case nsHtml5Tokenizer::CHARACTER_REFERENCE_TAIL:
       if (!aReconsume) {
         FlushCurrent();
       }
       EndSpanOrA();
       break;
-    case NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP:
-    case NS_HTML5TOKENIZER_HEX_NCR_LOOP:
+    case nsHtml5Tokenizer::DECIMAL_NRC_LOOP:
+    case nsHtml5Tokenizer::HEX_NCR_LOOP:
       switch (aState) {
-        case NS_HTML5TOKENIZER_HANDLE_NCR_VALUE:
+        case nsHtml5Tokenizer::HANDLE_NCR_VALUE:
           AddClass(sEntity);
           FlushCurrent();
           break;
-        case NS_HTML5TOKENIZER_HANDLE_NCR_VALUE_RECONSUME:
+        case nsHtml5Tokenizer::HANDLE_NCR_VALUE_RECONSUME:
           AddClass(sEntity);
           break;
       }
       EndSpanOrA();
       break;
-    case NS_HTML5TOKENIZER_CLOSE_TAG_OPEN:
+    case nsHtml5Tokenizer::CLOSE_TAG_OPEN:
       switch (aState) {
-        case NS_HTML5TOKENIZER_DATA:
+        case nsHtml5Tokenizer::DATA:
           FinishTag();
           break;
-        case NS_HTML5TOKENIZER_TAG_NAME:
+        case nsHtml5Tokenizer::TAG_NAME:
           StartSpan(sEndTag);
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN:
-      if (aState == NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME) {
+    case nsHtml5Tokenizer::RAWTEXT_RCDATA_LESS_THAN_SIGN:
+      if (aState == nsHtml5Tokenizer::NON_DATA_END_TAG_NAME) {
         FlushCurrent();
         StartSpan(); // don't know if it is "end-tag" yet :-(
         break;
       }
       EndSpanOrA();
       StartCharacters();
       break;
-    case NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME:
+    case nsHtml5Tokenizer::NON_DATA_END_TAG_NAME:
       switch (aState) {
-        case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME:
+        case nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME:
           AddClass(sEndTag);
           EndSpanOrA();
           break;
-        case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG:
+        case nsHtml5Tokenizer::SELF_CLOSING_START_TAG:
           AddClass(sEndTag);
           EndSpanOrA();
           StartSpan(); // for highlighting the slash
           mSlash = CurrentNode();
           break;
-        case NS_HTML5TOKENIZER_DATA: // yes, as a result of emitting the token
+        case nsHtml5Tokenizer::DATA: // yes, as a result of emitting the token
           AddClass(sEndTag);
           FinishTag();
           break;
         default:
           FinishTag();
           break;
       }
       break;
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:
-      if (aState == NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME) {
+    case nsHtml5Tokenizer::SCRIPT_DATA_LESS_THAN_SIGN:
+    case nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:
+      if (aState == nsHtml5Tokenizer::NON_DATA_END_TAG_NAME) {
         FlushCurrent();
         StartSpan(); // don't know if it is "end-tag" yet :-(
         break;
       }
       FinishTag();
       break;
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH:
-      if (aState == NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN) {
+    case nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_DASH_DASH:
+    case nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED:
+    case nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_DASH:
+      if (aState == nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN) {
         EndCharactersAndStartMarkupRun();
       }
       break;
       // Lots of double escape states omitted, because they don't highlight.
       // Likewise, only doctype states that can emit the doctype are of
       // interest. Otherwise, the transition out of bogus comment deals.
-    case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME:
-    case NS_HTML5TOKENIZER_DOCTYPE_NAME:
-    case NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME:
-    case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD:
-    case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:
-    case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:
-    case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER:
-    case NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:
-    case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:
-    case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER:
-    case NS_HTML5TOKENIZER_BOGUS_DOCTYPE:
-    case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD:
-    case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:
-    case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:
-    case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:
-      if (aState == NS_HTML5TOKENIZER_DATA) {
+    case nsHtml5Tokenizer::BEFORE_DOCTYPE_NAME:
+    case nsHtml5Tokenizer::DOCTYPE_NAME:
+    case nsHtml5Tokenizer::AFTER_DOCTYPE_NAME:
+    case nsHtml5Tokenizer::AFTER_DOCTYPE_PUBLIC_KEYWORD:
+    case nsHtml5Tokenizer::BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:
+    case nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:
+    case nsHtml5Tokenizer::AFTER_DOCTYPE_PUBLIC_IDENTIFIER:
+    case nsHtml5Tokenizer::BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:
+    case nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:
+    case nsHtml5Tokenizer::AFTER_DOCTYPE_SYSTEM_IDENTIFIER:
+    case nsHtml5Tokenizer::BOGUS_DOCTYPE:
+    case nsHtml5Tokenizer::AFTER_DOCTYPE_SYSTEM_KEYWORD:
+    case nsHtml5Tokenizer::BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:
+    case nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:
+    case nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:
+      if (aState == nsHtml5Tokenizer::DATA) {
         AddClass(sDoctype);
         FinishTag();
       }
       break;
-    case NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION_QUESTION_MARK:
-      if (aState == NS_HTML5TOKENIZER_DATA) {
+    case nsHtml5Tokenizer::PROCESSING_INSTRUCTION_QUESTION_MARK:
+      if (aState == nsHtml5Tokenizer::DATA) {
         FinishTag();
       }
       break;
     default:
       break;
   }
   mState = aState;
   return aState;
 }
 
 void
 nsHtml5Highlighter::End()
 {
   switch (mState) {
-    case NS_HTML5TOKENIZER_COMMENT_END:
-    case NS_HTML5TOKENIZER_COMMENT_END_BANG:
-    case NS_HTML5TOKENIZER_COMMENT_START_DASH:
-    case NS_HTML5TOKENIZER_BOGUS_COMMENT:
-    case NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN:
+    case nsHtml5Tokenizer::COMMENT_END:
+    case nsHtml5Tokenizer::COMMENT_END_BANG:
+    case nsHtml5Tokenizer::COMMENT_START_DASH:
+    case nsHtml5Tokenizer::BOGUS_COMMENT:
+    case nsHtml5Tokenizer::BOGUS_COMMENT_HYPHEN:
       AddClass(sComment);
       break;
-    case NS_HTML5TOKENIZER_CDATA_RSQB_RSQB:
+    case nsHtml5Tokenizer::CDATA_RSQB_RSQB:
       AddClass(sCdata);
       break;
-    case NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP:
-    case NS_HTML5TOKENIZER_HEX_NCR_LOOP:
+    case nsHtml5Tokenizer::DECIMAL_NRC_LOOP:
+    case nsHtml5Tokenizer::HEX_NCR_LOOP:
       // XXX need tokenizer help here
       break;
-    case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME:
-    case NS_HTML5TOKENIZER_DOCTYPE_NAME:
-    case NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME:
-    case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD:
-    case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:
-    case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:
-    case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER:
-    case NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:
-    case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:
-    case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER:
-    case NS_HTML5TOKENIZER_BOGUS_DOCTYPE:
-    case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD:
-    case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:
-    case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:
-    case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:
+    case nsHtml5Tokenizer::BEFORE_DOCTYPE_NAME:
+    case nsHtml5Tokenizer::DOCTYPE_NAME:
+    case nsHtml5Tokenizer::AFTER_DOCTYPE_NAME:
+    case nsHtml5Tokenizer::AFTER_DOCTYPE_PUBLIC_KEYWORD:
+    case nsHtml5Tokenizer::BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:
+    case nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:
+    case nsHtml5Tokenizer::AFTER_DOCTYPE_PUBLIC_IDENTIFIER:
+    case nsHtml5Tokenizer::BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:
+    case nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:
+    case nsHtml5Tokenizer::AFTER_DOCTYPE_SYSTEM_IDENTIFIER:
+    case nsHtml5Tokenizer::BOGUS_DOCTYPE:
+    case nsHtml5Tokenizer::AFTER_DOCTYPE_SYSTEM_KEYWORD:
+    case nsHtml5Tokenizer::BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:
+    case nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:
+    case nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:
       AddClass(sDoctype);
       break;
     default:
       break;
   }
   nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
   NS_ASSERTION(treeOp, "Tree op allocation failed.");
   treeOp->Init(eTreeOpStreamEnded);
--- a/parser/html/nsHtml5HtmlAttributes.cpp
+++ b/parser/html/nsHtml5HtmlAttributes.cpp
@@ -64,18 +64,18 @@ nsHtml5HtmlAttributes::~nsHtml5HtmlAttri
   MOZ_COUNT_DTOR(nsHtml5HtmlAttributes);
   clear(0);
 }
 
 int32_t
 nsHtml5HtmlAttributes::getIndex(nsHtml5AttributeName* aName)
 {
   for (size_t i = 0; i < mStorage.Length(); i++) {
-    if (mStorage[i].GetLocal(NS_HTML5ATTRIBUTE_NAME_HTML) ==
-        aName->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML)) {
+    if (mStorage[i].GetLocal(nsHtml5AttributeName::HTML) ==
+        aName->getLocal(nsHtml5AttributeName::HTML)) {
       // It's release asserted elsewhere that i can't be too large.
       return i;
     }
   }
   return -1;
 }
 
 nsHtml5String
@@ -177,60 +177,60 @@ nsHtml5HtmlAttributes::clearWithoutRelea
 {
   mStorage.TruncateLength(0);
 }
 
 bool
 nsHtml5HtmlAttributes::contains(nsHtml5AttributeName* aName)
 {
   for (size_t i = 0; i < mStorage.Length(); i++) {
-    if (mStorage[i].GetLocal(NS_HTML5ATTRIBUTE_NAME_HTML) ==
-        aName->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML)) {
+    if (mStorage[i].GetLocal(nsHtml5AttributeName::HTML) ==
+        aName->getLocal(nsHtml5AttributeName::HTML)) {
       return true;
     }
   }
   return false;
 }
 
 void 
 nsHtml5HtmlAttributes::adjustForMath()
 {
-  mMode = NS_HTML5ATTRIBUTE_NAME_MATHML;
+  mMode = nsHtml5AttributeName::MATHML;
 }
 
 void 
 nsHtml5HtmlAttributes::adjustForSvg()
 {
-  mMode = NS_HTML5ATTRIBUTE_NAME_SVG;
+  mMode = nsHtml5AttributeName::SVG;
 }
 
 nsHtml5HtmlAttributes*
 nsHtml5HtmlAttributes::cloneAttributes(nsHtml5AtomTable* aInterner)
 {
   MOZ_ASSERT(mStorage.IsEmpty() || !mMode);
   nsHtml5HtmlAttributes* clone =
-    new nsHtml5HtmlAttributes(NS_HTML5ATTRIBUTE_NAME_HTML);
+    new nsHtml5HtmlAttributes(nsHtml5AttributeName::HTML);
   for (nsHtml5AttributeEntry& entry : mStorage) {
     clone->AddEntry(entry.Clone(aInterner));
   }
   return clone;
 }
 
 bool
 nsHtml5HtmlAttributes::equalsAnother(nsHtml5HtmlAttributes* aOther)
 {
   MOZ_ASSERT(!mMode, "Trying to compare attributes in foreign content.");
   if (mStorage.Length() != aOther->mStorage.Length()) {
     return false;
   }
   for (nsHtml5AttributeEntry& entry : mStorage) {
     bool found = false;
-    nsIAtom* ownLocal = entry.GetLocal(NS_HTML5ATTRIBUTE_NAME_HTML);
+    nsIAtom* ownLocal = entry.GetLocal(nsHtml5AttributeName::HTML);
     for (nsHtml5AttributeEntry& otherEntry : aOther->mStorage) {
-      if (ownLocal == otherEntry.GetLocal(NS_HTML5ATTRIBUTE_NAME_HTML)) {
+      if (ownLocal == otherEntry.GetLocal(nsHtml5AttributeName::HTML)) {
         found = true;
         if (!entry.GetValue().Equals(otherEntry.GetValue())) {
           return false;
         }
         break;
       }
     }
     if (!found) {
@@ -244,17 +244,17 @@ void
 nsHtml5HtmlAttributes::AddEntry(nsHtml5AttributeEntry&& aEntry)
 {
   mStorage.AppendElement(aEntry);
 }
 
 void
 nsHtml5HtmlAttributes::initializeStatics()
 {
-  EMPTY_ATTRIBUTES = new nsHtml5HtmlAttributes(NS_HTML5ATTRIBUTE_NAME_HTML);
+  EMPTY_ATTRIBUTES = new nsHtml5HtmlAttributes(nsHtml5AttributeName::HTML);
 }
 
 void
 nsHtml5HtmlAttributes::releaseStatics()
 {
   delete EMPTY_ATTRIBUTES;
 }
 
--- a/parser/html/nsHtml5MetaScanner.cpp
+++ b/parser/html/nsHtml5MetaScanner.cpp
@@ -37,21 +37,22 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Atoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
+#include "nsHtml5Portability.h"
 
+#include "nsHtml5AttributeName.h"
+#include "nsHtml5ElementName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
-#include "nsHtml5AttributeName.h"
-#include "nsHtml5ElementName.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5StateSnapshot.h"
 #include "nsHtml5Portability.h"
 
 #include "nsHtml5MetaScanner.h"
 
 static char16_t const CHARSET_DATA[] = { 'h', 'a', 'r', 's', 'e', 't' };
@@ -59,29 +60,29 @@ staticJArray<char16_t,int32_t> nsHtml5Me
 static char16_t const CONTENT_DATA[] = { 'o', 'n', 't', 'e', 'n', 't' };
 staticJArray<char16_t,int32_t> nsHtml5MetaScanner::CONTENT = { CONTENT_DATA, MOZ_ARRAY_LENGTH(CONTENT_DATA) };
 static char16_t const HTTP_EQUIV_DATA[] = { 't', 't', 'p', '-', 'e', 'q', 'u', 'i', 'v' };
 staticJArray<char16_t,int32_t> nsHtml5MetaScanner::HTTP_EQUIV = { HTTP_EQUIV_DATA, MOZ_ARRAY_LENGTH(HTTP_EQUIV_DATA) };
 static char16_t const CONTENT_TYPE_DATA[] = { 'c', 'o', 'n', 't', 'e', 'n', 't', '-', 't', 'y', 'p', 'e' };
 staticJArray<char16_t,int32_t> nsHtml5MetaScanner::CONTENT_TYPE = { CONTENT_TYPE_DATA, MOZ_ARRAY_LENGTH(CONTENT_TYPE_DATA) };
 
 nsHtml5MetaScanner::nsHtml5MetaScanner(nsHtml5TreeBuilder* tb)
-  : readable(nullptr),
-    metaState(NS_HTML5META_SCANNER_NO),
-    contentIndex(INT32_MAX),
-    charsetIndex(INT32_MAX),
-    httpEquivIndex(INT32_MAX),
-    contentTypeIndex(INT32_MAX),
-    stateSave(NS_HTML5META_SCANNER_DATA),
-    strBufLen(0),
-    strBuf(jArray<char16_t,int32_t>::newJArray(36)),
-    content(nullptr),
-    charset(nullptr),
-    httpEquivState(NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN),
-    treeBuilder(tb)
+  : readable(nullptr)
+  , metaState(NO)
+  , contentIndex(INT32_MAX)
+  , charsetIndex(INT32_MAX)
+  , httpEquivIndex(INT32_MAX)
+  , contentTypeIndex(INT32_MAX)
+  , stateSave(DATA)
+  , strBufLen(0)
+  , strBuf(jArray<char16_t, int32_t>::newJArray(36))
+  , content(nullptr)
+  , charset(nullptr)
+  , httpEquivState(HTTP_EQUIV_NOT_SEEN)
+  , treeBuilder(tb)
 {
   MOZ_COUNT_CTOR(nsHtml5MetaScanner);
 }
 
 
 nsHtml5MetaScanner::~nsHtml5MetaScanner()
 {
   MOZ_COUNT_DTOR(nsHtml5MetaScanner);
@@ -91,136 +92,136 @@ nsHtml5MetaScanner::~nsHtml5MetaScanner(
 
 void 
 nsHtml5MetaScanner::stateLoop(int32_t state)
 {
   int32_t c = -1;
   bool reconsume = false;
   stateloop: for (; ; ) {
     switch(state) {
-      case NS_HTML5META_SCANNER_DATA: {
+      case DATA: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             c = read();
           }
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case '<': {
-              state = NS_HTML5META_SCANNER_TAG_OPEN;
+              state = nsHtml5MetaScanner::TAG_OPEN;
               NS_HTML5_BREAK(dataloop);
             }
             default: {
               continue;
             }
           }
         }
         dataloop_end: ;
       }
-      case NS_HTML5META_SCANNER_TAG_OPEN: {
+      case TAG_OPEN: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case 'm':
             case 'M': {
-              metaState = NS_HTML5META_SCANNER_M;
-              state = NS_HTML5META_SCANNER_TAG_NAME;
+              metaState = M;
+              state = nsHtml5MetaScanner::TAG_NAME;
               NS_HTML5_BREAK(tagopenloop);
             }
             case '!': {
-              state = NS_HTML5META_SCANNER_MARKUP_DECLARATION_OPEN;
+              state = nsHtml5MetaScanner::MARKUP_DECLARATION_OPEN;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\?':
             case '/': {
-              state = NS_HTML5META_SCANNER_SCAN_UNTIL_GT;
+              state = nsHtml5MetaScanner::SCAN_UNTIL_GT;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
-              state = NS_HTML5META_SCANNER_DATA;
+              state = nsHtml5MetaScanner::DATA;
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
-                metaState = NS_HTML5META_SCANNER_NO;
-                state = NS_HTML5META_SCANNER_TAG_NAME;
+                metaState = NO;
+                state = nsHtml5MetaScanner::TAG_NAME;
                 NS_HTML5_BREAK(tagopenloop);
               }
-              state = NS_HTML5META_SCANNER_DATA;
+              state = nsHtml5MetaScanner::DATA;
               reconsume = true;
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         tagopenloop_end: ;
       }
-      case NS_HTML5META_SCANNER_TAG_NAME: {
+      case TAG_NAME: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case ' ':
             case '\t':
             case '\n':
             case '\f': {
-              state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME;
+              state = nsHtml5MetaScanner::BEFORE_ATTRIBUTE_NAME;
               NS_HTML5_BREAK(tagnameloop);
             }
             case '/': {
-              state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG;
+              state = nsHtml5MetaScanner::SELF_CLOSING_START_TAG;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
-              state = NS_HTML5META_SCANNER_DATA;
+              state = nsHtml5MetaScanner::DATA;
               NS_HTML5_CONTINUE(stateloop);
             }
             case 'e':
             case 'E': {
-              if (metaState == NS_HTML5META_SCANNER_M) {
-                metaState = NS_HTML5META_SCANNER_E;
+              if (metaState == M) {
+                metaState = E;
               } else {
-                metaState = NS_HTML5META_SCANNER_NO;
+                metaState = NO;
               }
               continue;
             }
             case 't':
             case 'T': {
-              if (metaState == NS_HTML5META_SCANNER_E) {
-                metaState = NS_HTML5META_SCANNER_T;
+              if (metaState == E) {
+                metaState = T;
               } else {
-                metaState = NS_HTML5META_SCANNER_NO;
+                metaState = NO;
               }
               continue;
             }
             case 'a':
             case 'A': {
-              if (metaState == NS_HTML5META_SCANNER_T) {
-                metaState = NS_HTML5META_SCANNER_A;
+              if (metaState == T) {
+                metaState = A;
               } else {
-                metaState = NS_HTML5META_SCANNER_NO;
+                metaState = NO;
               }
               continue;
             }
             default: {
-              metaState = NS_HTML5META_SCANNER_NO;
+              metaState = NO;
               continue;
             }
           }
         }
         tagnameloop_end: ;
       }
-      case NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME: {
+      case BEFORE_ATTRIBUTE_NAME: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             c = read();
           }
           switch(c) {
             case -1: {
@@ -228,89 +229,89 @@ nsHtml5MetaScanner::stateLoop(int32_t st
             }
             case ' ':
             case '\t':
             case '\n':
             case '\f': {
               continue;
             }
             case '/': {
-              state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG;
+              state = nsHtml5MetaScanner::SELF_CLOSING_START_TAG;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               if (handleTag()) {
                 NS_HTML5_BREAK(stateloop);
               }
-              state = NS_HTML5META_SCANNER_DATA;
+              state = DATA;
               NS_HTML5_CONTINUE(stateloop);
             }
             case 'c':
             case 'C': {
               contentIndex = 0;
               charsetIndex = 0;
               httpEquivIndex = INT32_MAX;
               contentTypeIndex = INT32_MAX;
-              state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME;
+              state = nsHtml5MetaScanner::ATTRIBUTE_NAME;
               NS_HTML5_BREAK(beforeattributenameloop);
             }
             case 'h':
             case 'H': {
               contentIndex = INT32_MAX;
               charsetIndex = INT32_MAX;
               httpEquivIndex = 0;
               contentTypeIndex = INT32_MAX;
-              state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME;
+              state = nsHtml5MetaScanner::ATTRIBUTE_NAME;
               NS_HTML5_BREAK(beforeattributenameloop);
             }
             default: {
               contentIndex = INT32_MAX;
               charsetIndex = INT32_MAX;
               httpEquivIndex = INT32_MAX;
               contentTypeIndex = INT32_MAX;
-              state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME;
+              state = nsHtml5MetaScanner::ATTRIBUTE_NAME;
               NS_HTML5_BREAK(beforeattributenameloop);
             }
           }
         }
         beforeattributenameloop_end: ;
       }
-      case NS_HTML5META_SCANNER_ATTRIBUTE_NAME: {
+      case ATTRIBUTE_NAME: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case ' ':
             case '\t':
             case '\n':
             case '\f': {
-              state = NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_NAME;
+              state = nsHtml5MetaScanner::AFTER_ATTRIBUTE_NAME;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '/': {
-              state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG;
+              state = nsHtml5MetaScanner::SELF_CLOSING_START_TAG;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '=': {
               strBufLen = 0;
               contentTypeIndex = 0;
-              state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_VALUE;
+              state = nsHtml5MetaScanner::BEFORE_ATTRIBUTE_VALUE;
               NS_HTML5_BREAK(attributenameloop);
             }
             case '>': {
               if (handleTag()) {
                 NS_HTML5_BREAK(stateloop);
               }
-              state = NS_HTML5META_SCANNER_DATA;
+              state = nsHtml5MetaScanner::DATA;
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
-              if (metaState == NS_HTML5META_SCANNER_A) {
+              if (metaState == A) {
                 if (c >= 'A' && c <= 'Z') {
                   c += 0x20;
                 }
                 if (contentIndex < CONTENT.length && c == CONTENT[contentIndex]) {
                   ++contentIndex;
                 } else {
                   contentIndex = INT32_MAX;
                 }
@@ -326,390 +327,390 @@ nsHtml5MetaScanner::stateLoop(int32_t st
                 }
               }
               continue;
             }
           }
         }
         attributenameloop_end: ;
       }
-      case NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_VALUE: {
+      case BEFORE_ATTRIBUTE_VALUE: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case ' ':
             case '\t':
             case '\n':
             case '\f': {
               continue;
             }
             case '\"': {
-              state = NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_DOUBLE_QUOTED;
+              state = nsHtml5MetaScanner::ATTRIBUTE_VALUE_DOUBLE_QUOTED;
               NS_HTML5_BREAK(beforeattributevalueloop);
             }
             case '\'': {
-              state = NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_SINGLE_QUOTED;
+              state = nsHtml5MetaScanner::ATTRIBUTE_VALUE_SINGLE_QUOTED;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               if (handleTag()) {
                 NS_HTML5_BREAK(stateloop);
               }
-              state = NS_HTML5META_SCANNER_DATA;
+              state = nsHtml5MetaScanner::DATA;
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               handleCharInAttributeValue(c);
-              state = NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_UNQUOTED;
+              state = nsHtml5MetaScanner::ATTRIBUTE_VALUE_UNQUOTED;
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         beforeattributevalueloop_end: ;
       }
-      case NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
+      case ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             c = read();
           }
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case '\"': {
               handleAttributeValue();
-              state = NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED;
+              state = nsHtml5MetaScanner::AFTER_ATTRIBUTE_VALUE_QUOTED;
               NS_HTML5_BREAK(attributevaluedoublequotedloop);
             }
             default: {
               handleCharInAttributeValue(c);
               continue;
             }
           }
         }
         attributevaluedoublequotedloop_end: ;
       }
-      case NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED: {
+      case AFTER_ATTRIBUTE_VALUE_QUOTED: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case ' ':
             case '\t':
             case '\n':
             case '\f': {
-              state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME;
+              state = nsHtml5MetaScanner::BEFORE_ATTRIBUTE_NAME;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '/': {
-              state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG;
+              state = nsHtml5MetaScanner::SELF_CLOSING_START_TAG;
               NS_HTML5_BREAK(afterattributevaluequotedloop);
             }
             case '>': {
               if (handleTag()) {
                 NS_HTML5_BREAK(stateloop);
               }
-              state = NS_HTML5META_SCANNER_DATA;
+              state = nsHtml5MetaScanner::DATA;
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
-              state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME;
+              state = nsHtml5MetaScanner::BEFORE_ATTRIBUTE_NAME;
               reconsume = true;
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         afterattributevaluequotedloop_end: ;
       }
-      case NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG: {
+      case SELF_CLOSING_START_TAG: {
         c = read();
         switch(c) {
           case -1: {
             NS_HTML5_BREAK(stateloop);
           }
           case '>': {
             if (handleTag()) {
               NS_HTML5_BREAK(stateloop);
             }
-            state = NS_HTML5META_SCANNER_DATA;
+            state = nsHtml5MetaScanner::DATA;
             NS_HTML5_CONTINUE(stateloop);
           }
           default: {
-            state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME;
+            state = nsHtml5MetaScanner::BEFORE_ATTRIBUTE_NAME;
             reconsume = true;
             NS_HTML5_CONTINUE(stateloop);
           }
         }
       }
-      case NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_UNQUOTED: {
+      case ATTRIBUTE_VALUE_UNQUOTED: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             c = read();
           }
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case ' ':
             case '\t':
             case '\n':
             case '\f': {
               handleAttributeValue();
-              state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME;
+              state = nsHtml5MetaScanner::BEFORE_ATTRIBUTE_NAME;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               handleAttributeValue();
               if (handleTag()) {
                 NS_HTML5_BREAK(stateloop);
               }
-              state = NS_HTML5META_SCANNER_DATA;
+              state = nsHtml5MetaScanner::DATA;
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               handleCharInAttributeValue(c);
               continue;
             }
           }
         }
       }
-      case NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_NAME: {
+      case AFTER_ATTRIBUTE_NAME: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case ' ':
             case '\t':
             case '\n':
             case '\f': {
               continue;
             }
             case '/': {
               handleAttributeValue();
-              state = NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG;
+              state = nsHtml5MetaScanner::SELF_CLOSING_START_TAG;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '=': {
               strBufLen = 0;
               contentTypeIndex = 0;
-              state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_VALUE;
+              state = nsHtml5MetaScanner::BEFORE_ATTRIBUTE_VALUE;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               handleAttributeValue();
               if (handleTag()) {
                 NS_HTML5_BREAK(stateloop);
               }
-              state = NS_HTML5META_SCANNER_DATA;
+              state = nsHtml5MetaScanner::DATA;
               NS_HTML5_CONTINUE(stateloop);
             }
             case 'c':
             case 'C': {
               contentIndex = 0;
               charsetIndex = 0;
-              state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME;
+              state = nsHtml5MetaScanner::ATTRIBUTE_NAME;
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               contentIndex = INT32_MAX;
               charsetIndex = INT32_MAX;
-              state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME;
+              state = nsHtml5MetaScanner::ATTRIBUTE_NAME;
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
       }
-      case NS_HTML5META_SCANNER_MARKUP_DECLARATION_OPEN: {
+      case MARKUP_DECLARATION_OPEN: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case '-': {
-              state = NS_HTML5META_SCANNER_MARKUP_DECLARATION_HYPHEN;
+              state = nsHtml5MetaScanner::MARKUP_DECLARATION_HYPHEN;
               NS_HTML5_BREAK(markupdeclarationopenloop);
             }
             default: {
-              state = NS_HTML5META_SCANNER_SCAN_UNTIL_GT;
+              state = nsHtml5MetaScanner::SCAN_UNTIL_GT;
               reconsume = true;
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         markupdeclarationopenloop_end: ;
       }
-      case NS_HTML5META_SCANNER_MARKUP_DECLARATION_HYPHEN: {
+      case MARKUP_DECLARATION_HYPHEN: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case '-': {
-              state = NS_HTML5META_SCANNER_COMMENT_START;
+              state = nsHtml5MetaScanner::COMMENT_START;
               NS_HTML5_BREAK(markupdeclarationhyphenloop);
             }
             default: {
-              state = NS_HTML5META_SCANNER_SCAN_UNTIL_GT;
+              state = nsHtml5MetaScanner::SCAN_UNTIL_GT;
               reconsume = true;
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         markupdeclarationhyphenloop_end: ;
       }
-      case NS_HTML5META_SCANNER_COMMENT_START: {
+      case COMMENT_START: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case '-': {
-              state = NS_HTML5META_SCANNER_COMMENT_START_DASH;
+              state = nsHtml5MetaScanner::COMMENT_START_DASH;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
-              state = NS_HTML5META_SCANNER_DATA;
+              state = nsHtml5MetaScanner::DATA;
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
-              state = NS_HTML5META_SCANNER_COMMENT;
+              state = nsHtml5MetaScanner::COMMENT;
               NS_HTML5_BREAK(commentstartloop);
             }
           }
         }
         commentstartloop_end: ;
       }
-      case NS_HTML5META_SCANNER_COMMENT: {
+      case COMMENT: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case '-': {
-              state = NS_HTML5META_SCANNER_COMMENT_END_DASH;
+              state = nsHtml5MetaScanner::COMMENT_END_DASH;
               NS_HTML5_BREAK(commentloop);
             }
             default: {
               continue;
             }
           }
         }
         commentloop_end: ;
       }
-      case NS_HTML5META_SCANNER_COMMENT_END_DASH: {
+      case COMMENT_END_DASH: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case '-': {
-              state = NS_HTML5META_SCANNER_COMMENT_END;
+              state = nsHtml5MetaScanner::COMMENT_END;
               NS_HTML5_BREAK(commentenddashloop);
             }
             default: {
-              state = NS_HTML5META_SCANNER_COMMENT;
+              state = nsHtml5MetaScanner::COMMENT;
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         commentenddashloop_end: ;
       }
-      case NS_HTML5META_SCANNER_COMMENT_END: {
+      case COMMENT_END: {
         for (; ; ) {
           c = read();
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case '>': {
-              state = NS_HTML5META_SCANNER_DATA;
+              state = nsHtml5MetaScanner::DATA;
               NS_HTML5_CONTINUE(stateloop);
             }
             case '-': {
               continue;
             }
             default: {
-              state = NS_HTML5META_SCANNER_COMMENT;
+              state = nsHtml5MetaScanner::COMMENT;
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
       }
-      case NS_HTML5META_SCANNER_COMMENT_START_DASH: {
+      case COMMENT_START_DASH: {
         c = read();
         switch(c) {
           case -1: {
             NS_HTML5_BREAK(stateloop);
           }
           case '-': {
-            state = NS_HTML5META_SCANNER_COMMENT_END;
+            state = nsHtml5MetaScanner::COMMENT_END;
             NS_HTML5_CONTINUE(stateloop);
           }
           case '>': {
-            state = NS_HTML5META_SCANNER_DATA;
+            state = nsHtml5MetaScanner::DATA;
             NS_HTML5_CONTINUE(stateloop);
           }
           default: {
-            state = NS_HTML5META_SCANNER_COMMENT;
+            state = nsHtml5MetaScanner::COMMENT;
             NS_HTML5_CONTINUE(stateloop);
           }
         }
       }
-      case NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_SINGLE_QUOTED: {
+      case ATTRIBUTE_VALUE_SINGLE_QUOTED: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             c = read();
           }
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case '\'': {
               handleAttributeValue();
-              state = NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED;
+              state = nsHtml5MetaScanner::AFTER_ATTRIBUTE_VALUE_QUOTED;
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               handleCharInAttributeValue(c);
               continue;
             }
           }
         }
       }
-      case NS_HTML5META_SCANNER_SCAN_UNTIL_GT: {
+      case SCAN_UNTIL_GT: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             c = read();
           }
           switch(c) {
             case -1: {
               NS_HTML5_BREAK(stateloop);
             }
             case '>': {
-              state = NS_HTML5META_SCANNER_DATA;
+              state = nsHtml5MetaScanner::DATA;
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               continue;
             }
           }
         }
       }
@@ -717,17 +718,17 @@ nsHtml5MetaScanner::stateLoop(int32_t st
   }
   stateloop_end: ;
   stateSave = state;
 }
 
 void 
 nsHtml5MetaScanner::handleCharInAttributeValue(int32_t c)
 {
-  if (metaState == NS_HTML5META_SCANNER_A) {
+  if (metaState == A) {
     if (contentIndex == CONTENT.length || charsetIndex == CHARSET.length) {
       addToBuffer(c);
     } else if (httpEquivIndex == HTTP_EQUIV.length) {
       if (contentTypeIndex < CONTENT_TYPE.length && toAsciiLowerCase(c) == CONTENT_TYPE[contentTypeIndex]) {
         ++contentTypeIndex;
       } else {
         contentTypeIndex = INT32_MAX;
       }
@@ -744,52 +745,55 @@ nsHtml5MetaScanner::addToBuffer(int32_t 
     strBuf = newBuf;
   }
   strBuf[strBufLen++] = (char16_t) c;
 }
 
 void 
 nsHtml5MetaScanner::handleAttributeValue()
 {
-  if (metaState != NS_HTML5META_SCANNER_A) {
+  if (metaState != A) {
     return;
   }
   if (contentIndex == CONTENT.length && !content) {
     content = nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen, treeBuilder);
     return;
   }
   if (charsetIndex == CHARSET.length && !charset) {
     charset = nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen, treeBuilder);
     return;
   }
-  if (httpEquivIndex == HTTP_EQUIV.length && httpEquivState == NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN) {
-    httpEquivState = (contentTypeIndex == CONTENT_TYPE.length) ? NS_HTML5META_SCANNER_HTTP_EQUIV_CONTENT_TYPE : NS_HTML5META_SCANNER_HTTP_EQUIV_OTHER;
+  if (httpEquivIndex == HTTP_EQUIV.length &&
+      httpEquivState == HTTP_EQUIV_NOT_SEEN) {
+    httpEquivState = (contentTypeIndex == CONTENT_TYPE.length)
+                       ? HTTP_EQUIV_CONTENT_TYPE
+                       : HTTP_EQUIV_OTHER;
     return;
   }
 }
 
 bool 
 nsHtml5MetaScanner::handleTag()
 {
   bool stop = handleTagInner();
   content.Release();
   content = nullptr;
   charset.Release();
   charset = nullptr;
-  httpEquivState = NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN;
+  httpEquivState = HTTP_EQUIV_NOT_SEEN;
   return stop;
 }
 
 bool 
 nsHtml5MetaScanner::handleTagInner()
 {
   if (!!charset && tryCharset(charset)) {
     return true;
   }
-  if (!!content && httpEquivState == NS_HTML5META_SCANNER_HTTP_EQUIV_CONTENT_TYPE) {
+  if (!!content && httpEquivState == HTTP_EQUIV_CONTENT_TYPE) {
     nsHtml5String extract =
       nsHtml5TreeBuilder::extractCharsetFromContent(content, treeBuilder);
     if (!extract) {
       return false;
     }
     bool success = tryCharset(extract);
     extract.Release();
     return success;
--- a/parser/html/nsHtml5MetaScanner.h
+++ b/parser/html/nsHtml5MetaScanner.h
@@ -38,35 +38,92 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Atoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
+#include "nsHtml5Portability.h"
 
 class nsHtml5StreamParser;
 
+class nsHtml5AttributeName;
+class nsHtml5ElementName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
-class nsHtml5AttributeName;
-class nsHtml5ElementName;
 class nsHtml5UTF16Buffer;
 class nsHtml5StateSnapshot;
 class nsHtml5Portability;
 
 
 class nsHtml5MetaScanner
 {
   private:
     static staticJArray<char16_t,int32_t> CHARSET;
     static staticJArray<char16_t,int32_t> CONTENT;
     static staticJArray<char16_t,int32_t> HTTP_EQUIV;
     static staticJArray<char16_t,int32_t> CONTENT_TYPE;
+    static const int32_t NO = 0;
+
+    static const int32_t M = 1;
+
+    static const int32_t E = 2;
+
+    static const int32_t T = 3;
+
+    static const int32_t A = 4;
+
+    static const int32_t DATA = 0;
+
+    static const int32_t TAG_OPEN = 1;
+
+    static const int32_t SCAN_UNTIL_GT = 2;
+
+    static const int32_t TAG_NAME = 3;
+
+    static const int32_t BEFORE_ATTRIBUTE_NAME = 4;
+
+    static const int32_t ATTRIBUTE_NAME = 5;
+
+    static const int32_t AFTER_ATTRIBUTE_NAME = 6;
+
+    static const int32_t BEFORE_ATTRIBUTE_VALUE = 7;
+
+    static const int32_t ATTRIBUTE_VALUE_DOUBLE_QUOTED = 8;
+
+    static const int32_t ATTRIBUTE_VALUE_SINGLE_QUOTED = 9;
+
+    static const int32_t ATTRIBUTE_VALUE_UNQUOTED = 10;
+
+    static const int32_t AFTER_ATTRIBUTE_VALUE_QUOTED = 11;
+
+    static const int32_t MARKUP_DECLARATION_OPEN = 13;
+
+    static const int32_t MARKUP_DECLARATION_HYPHEN = 14;
+
+    static const int32_t COMMENT_START = 15;
+
+    static const int32_t COMMENT_START_DASH = 16;
+
+    static const int32_t COMMENT = 17;
+
+    static const int32_t COMMENT_END_DASH = 18;
+
+    static const int32_t COMMENT_END = 19;
+
+    static const int32_t SELF_CLOSING_START_TAG = 20;
+
+    static const int32_t HTTP_EQUIV_NOT_SEEN = 0;
+
+    static const int32_t HTTP_EQUIV_CONTENT_TYPE = 1;
+
+    static const int32_t HTTP_EQUIV_OTHER = 2;
+
   protected:
     nsHtml5ByteReadable* readable;
   private:
     int32_t metaState;
     int32_t contentIndex;
     int32_t charsetIndex;
     int32_t httpEquivIndex;
     int32_t contentTypeIndex;
@@ -102,40 +159,10 @@ class nsHtml5MetaScanner
     bool tryCharset(nsHtml5String encoding);
   public:
     static void initializeStatics();
     static void releaseStatics();
 
 #include "nsHtml5MetaScannerHSupplement.h"
 };
 
-#define NS_HTML5META_SCANNER_NO 0
-#define NS_HTML5META_SCANNER_M 1
-#define NS_HTML5META_SCANNER_E 2
-#define NS_HTML5META_SCANNER_T 3
-#define NS_HTML5META_SCANNER_A 4
-#define NS_HTML5META_SCANNER_DATA 0
-#define NS_HTML5META_SCANNER_TAG_OPEN 1
-#define NS_HTML5META_SCANNER_SCAN_UNTIL_GT 2
-#define NS_HTML5META_SCANNER_TAG_NAME 3
-#define NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME 4
-#define NS_HTML5META_SCANNER_ATTRIBUTE_NAME 5
-#define NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_NAME 6
-#define NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_VALUE 7
-#define NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_DOUBLE_QUOTED 8
-#define NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_SINGLE_QUOTED 9
-#define NS_HTML5META_SCANNER_ATTRIBUTE_VALUE_UNQUOTED 10
-#define NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED 11
-#define NS_HTML5META_SCANNER_MARKUP_DECLARATION_OPEN 13
-#define NS_HTML5META_SCANNER_MARKUP_DECLARATION_HYPHEN 14
-#define NS_HTML5META_SCANNER_COMMENT_START 15
-#define NS_HTML5META_SCANNER_COMMENT_START_DASH 16
-#define NS_HTML5META_SCANNER_COMMENT 17
-#define NS_HTML5META_SCANNER_COMMENT_END_DASH 18
-#define NS_HTML5META_SCANNER_COMMENT_END 19
-#define NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG 20
-#define NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN 0
-#define NS_HTML5META_SCANNER_HTTP_EQUIV_CONTENT_TYPE 1
-#define NS_HTML5META_SCANNER_HTTP_EQUIV_OTHER 2
-
-
 #endif
 
--- a/parser/html/nsHtml5Portability.h
+++ b/parser/html/nsHtml5Portability.h
@@ -40,21 +40,21 @@
 #include "nsHtml5Atoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
 
 class nsHtml5StreamParser;
 
+class nsHtml5AttributeName;
+class nsHtml5ElementName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
-class nsHtml5AttributeName;
-class nsHtml5ElementName;
 class nsHtml5UTF16Buffer;
 class nsHtml5StateSnapshot;
 
 
 class nsHtml5Portability
 {
   public:
     static nsIAtom* newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
@@ -77,12 +77,10 @@ class nsHtml5Portability
       const char* lowerCaseLiteral,
       nsHtml5String string);
     static bool literalEqualsString(const char* literal, nsHtml5String string);
     static bool stringEqualsString(nsHtml5String one, nsHtml5String other);
     static void initializeStatics();
     static void releaseStatics();
 };
 
-
-
 #endif
 
--- a/parser/html/nsHtml5StackNode.cpp
+++ b/parser/html/nsHtml5StackNode.cpp
@@ -37,56 +37,57 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Atoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
+#include "nsHtml5Portability.h"
 
+#include "nsHtml5AttributeName.h"
+#include "nsHtml5ElementName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5MetaScanner.h"
-#include "nsHtml5AttributeName.h"
-#include "nsHtml5ElementName.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5StateSnapshot.h"
 #include "nsHtml5Portability.h"
 
 #include "nsHtml5StackNode.h"
 
 int32_t 
 nsHtml5StackNode::getGroup()
 {
-  return flags & NS_HTML5ELEMENT_NAME_GROUP_MASK;
+  return flags & nsHtml5ElementName::GROUP_MASK;
 }
 
 bool 
 nsHtml5StackNode::isScoping()
 {
-  return (flags & NS_HTML5ELEMENT_NAME_SCOPING);
+  return (flags & nsHtml5ElementName::SCOPING);
 }
 
 bool 
 nsHtml5StackNode::isSpecial()
 {
-  return (flags & NS_HTML5ELEMENT_NAME_SPECIAL);
+  return (flags & nsHtml5ElementName::SPECIAL);
 }
 
 bool 
 nsHtml5StackNode::isFosterParenting()
 {
-  return (flags & NS_HTML5ELEMENT_NAME_FOSTER_PARENTING);
+  return (flags & nsHtml5ElementName::FOSTER_PARENTING);
 }
 
 bool 
 nsHtml5StackNode::isHtmlIntegrationPoint()
 {
-  return (flags & NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT);
+  return (flags & nsHtml5ElementName::HTML_INTEGRATION_POINT);
 }
 
 
 nsHtml5StackNode::nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContentHandle* node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
   : flags(flags),
     name(name),
     popName(popName),
     ns(ns),
@@ -169,32 +170,37 @@ nsHtml5StackNode::nsHtml5StackNode(nsHtm
   , refcount(1)
 {
   MOZ_COUNT_CTOR(nsHtml5StackNode);
 }
 
 int32_t 
 nsHtml5StackNode::prepareSvgFlags(int32_t flags)
 {
-  flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
-  if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG)) {
-    flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT);
+  flags &=
+    ~(nsHtml5ElementName::FOSTER_PARENTING | nsHtml5ElementName::SCOPING |
+      nsHtml5ElementName::SPECIAL | nsHtml5ElementName::OPTIONAL_END_TAG);
+  if ((flags & nsHtml5ElementName::SCOPING_AS_SVG)) {
+    flags |= (nsHtml5ElementName::SCOPING | nsHtml5ElementName::SPECIAL |
+              nsHtml5ElementName::HTML_INTEGRATION_POINT);
   }
   return flags;
 }
 
 int32_t 
 nsHtml5StackNode::prepareMathFlags(int32_t flags, bool markAsIntegrationPoint)
 {
-  flags &= ~(NS_HTML5ELEMENT_NAME_FOSTER_PARENTING | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
-  if ((flags & NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML)) {
-    flags |= (NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_SPECIAL);
+  flags &=
+    ~(nsHtml5ElementName::FOSTER_PARENTING | nsHtml5ElementName::SCOPING |
+      nsHtml5ElementName::SPECIAL | nsHtml5ElementName::OPTIONAL_END_TAG);
+  if ((flags & nsHtml5ElementName::SCOPING_AS_MATHML)) {
+    flags |= (nsHtml5ElementName::SCOPING | nsHtml5ElementName::SPECIAL);
   }
   if (markAsIntegrationPoint) {
-    flags |= NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT;
+    flags |= nsHtml5ElementName::HTML_INTEGRATION_POINT;
   }
   return flags;
 }
 
 
 nsHtml5StackNode::~nsHtml5StackNode()
 {
   MOZ_COUNT_DTOR(nsHtml5StackNode);
--- a/parser/html/nsHtml5StackNode.h
+++ b/parser/html/nsHtml5StackNode.h
@@ -38,24 +38,25 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Atoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
+#include "nsHtml5Portability.h"
 
 class nsHtml5StreamParser;
 
+class nsHtml5AttributeName;
+class nsHtml5ElementName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
-class nsHtml5AttributeName;
-class nsHtml5ElementName;
 class nsHtml5UTF16Buffer;
 class nsHtml5StateSnapshot;
 class nsHtml5Portability;
 
 
 class nsHtml5StackNode
 {
   public:
@@ -91,12 +92,10 @@ class nsHtml5StackNode
     ~nsHtml5StackNode();
     void dropAttributes();
     void retain();
     void release();
     static void initializeStatics();
     static void releaseStatics();
 };
 
-
-
 #endif
 
--- a/parser/html/nsHtml5StateSnapshot.cpp
+++ b/parser/html/nsHtml5StateSnapshot.cpp
@@ -36,22 +36,23 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Atoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
+#include "nsHtml5Portability.h"
 
+#include "nsHtml5AttributeName.h"
+#include "nsHtml5ElementName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5MetaScanner.h"
-#include "nsHtml5AttributeName.h"
-#include "nsHtml5ElementName.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5Portability.h"
 
 #include "nsHtml5StateSnapshot.h"
 
 
 nsHtml5StateSnapshot::nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,int32_t> stack, jArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements, jArray<int32_t,int32_t> templateModeStack, nsIContentHandle* formPointer, nsIContentHandle* headPointer, nsIContentHandle* deepTreeSurrogateParent, int32_t mode, int32_t originalMode, bool framesetOk, bool needToDropLF, bool quirks)
--- a/parser/html/nsHtml5StateSnapshot.h
+++ b/parser/html/nsHtml5StateSnapshot.h
@@ -37,24 +37,25 @@
 #include "jArray.h"
 #include "nsHtml5ArrayCopy.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Atoms.h"
 #include "nsHtml5ByteReadable.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsHtml5Macros.h"
 #include "nsIContentHandle.h"
+#include "nsHtml5Portability.h"
 
 class nsHtml5StreamParser;
 
+class nsHtml5AttributeName;
+class nsHtml5ElementName;
 class nsHtml5Tokenizer;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
-class nsHtml5AttributeName;
-class nsHtml5ElementName;
 class nsHtml5UTF16Buffer;
 class nsHtml5Portability;
 
 
 class nsHtml5StateSnapshot : public nsAHtml5TreeBuilderState
 {
   private:
     autoJArray<nsHtml5StackNode*,int32_t> stack;
@@ -84,12 +85,10 @@ class nsHtml5StateSnapshot : public nsAH
     int32_t getListOfActiveFormattingElementsLength();
     int32_t getStackLength();
     int32_t getTemplateModeStackLength();
     ~nsHtml5StateSnapshot();
     static void initializeStatics();
     static void releaseStatics();
 };
 
-
-
 #endif
 
--- a/parser/html/nsHtml5Tokenizer.cpp
+++ b/parser/html/nsHtml5Tokenizer.cpp
@@ -41,20 +41,20 @@
 #include "nsHtml5NamedCharacters.h"
 #include "nsHtml5NamedCharactersAccel.h"
 #include "nsHtml5Atoms.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Macros.h"
 #include "nsHtml5Highlighter.h"
 #include "nsHtml5TokenizerLoopPolicies.h"
 
+#include "nsHtml5AttributeName.h"
+#include "nsHtml5ElementName.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5MetaScanner.h"
-#include "nsHtml5AttributeName.h"
-#include "nsHtml5ElementName.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5StateSnapshot.h"
 #include "nsHtml5Portability.h"
 
 #include "nsHtml5Tokenizer.h"
 
 char16_t nsHtml5Tokenizer::LT_GT[] = { '<', '>' };
@@ -129,17 +129,17 @@ nsHtml5Tokenizer::isViewingXmlSource()
 {
   return viewingXmlSource;
 }
 
 void 
 nsHtml5Tokenizer::setStateAndEndTagExpectation(int32_t specialTokenizerState, nsIAtom* endTagExpectation)
 {
   this->stateSave = specialTokenizerState;
-  if (specialTokenizerState == NS_HTML5TOKENIZER_DATA) {
+  if (specialTokenizerState == nsHtml5Tokenizer::DATA) {
     return;
   }
   autoJArray<char16_t,int32_t> asArray = nsHtml5Portability::newCharArrayFromLocal(endTagExpectation);
   this->endTagExpectation = nsHtml5ElementName::elementNameByBuffer(asArray, 0, asArray.length, interner);
   MOZ_ASSERT(!!this->endTagExpectation);
   endTagExpectationToArray();
 }
 
@@ -150,53 +150,53 @@ nsHtml5Tokenizer::setStateAndEndTagExpec
   this->endTagExpectation = endTagExpectation;
   endTagExpectationToArray();
 }
 
 void 
 nsHtml5Tokenizer::endTagExpectationToArray()
 {
   switch(endTagExpectation->getGroup()) {
-    case NS_HTML5TREE_BUILDER_TITLE: {
+    case nsHtml5TreeBuilder::TITLE: {
       endTagExpectationAsArray = TITLE_ARR;
       return;
     }
-    case NS_HTML5TREE_BUILDER_SCRIPT: {
+    case nsHtml5TreeBuilder::SCRIPT: {
       endTagExpectationAsArray = SCRIPT_ARR;
       return;
     }
-    case NS_HTML5TREE_BUILDER_STYLE: {
+    case nsHtml5TreeBuilder::STYLE: {
       endTagExpectationAsArray = STYLE_ARR;
       return;
     }
-    case NS_HTML5TREE_BUILDER_PLAINTEXT: {
+    case nsHtml5TreeBuilder::PLAINTEXT: {
       endTagExpectationAsArray = PLAINTEXT_ARR;
       return;
     }
-    case NS_HTML5TREE_BUILDER_XMP: {
+    case nsHtml5TreeBuilder::XMP: {
       endTagExpectationAsArray = XMP_ARR;
       return;
     }
-    case NS_HTML5TREE_BUILDER_TEXTAREA: {
+    case nsHtml5TreeBuilder::TEXTAREA: {
       endTagExpectationAsArray = TEXTAREA_ARR;
       return;
     }
-    case NS_HTML5TREE_BUILDER_IFRAME: {
+    case nsHtml5TreeBuilder::IFRAME: {
       endTagExpectationAsArray = IFRAME_ARR;
       return;
     }
-    case NS_HTML5TREE_BUILDER_NOEMBED: {
+    case nsHtml5TreeBuilder::NOEMBED: {
       endTagExpectationAsArray = NOEMBED_ARR;
       return;
     }
-    case NS_HTML5TREE_BUILDER_NOSCRIPT: {
+    case nsHtml5TreeBuilder::NOSCRIPT: {
       endTagExpectationAsArray = NOSCRIPT_ARR;
       return;
     }
-    case NS_HTML5TREE_BUILDER_NOFRAMES: {
+    case nsHtml5TreeBuilder::NOFRAMES: {
       endTagExpectationAsArray = NOFRAMES_ARR;
       return;
     }
     default: {
       MOZ_ASSERT(false, "Bad end tag expectation.");
       return;
     }
   }
@@ -213,17 +213,17 @@ nsHtml5HtmlAttributes*
 nsHtml5Tokenizer::emptyAttributes()
 {
   return nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES;
 }
 
 void 
 nsHtml5Tokenizer::emitOrAppendCharRefBuf(int32_t returnState)
 {
-  if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+  if ((returnState & DATA_AND_RCDATA_MASK)) {
     appendCharRefBufToStrBuf();
   } else {
     if (charRefBufLen > 0) {
       tokenHandler->characters(charRefBuf, 0, charRefBufLen);
       charRefBufLen = 0;
     }
   }
 }
@@ -312,17 +312,17 @@ nsHtml5Tokenizer::strBufToElementNameStr
   clearStrBufAfterUse();
 }
 
 int32_t 
 nsHtml5Tokenizer::emitCurrentTagToken(bool selfClosing, int32_t pos)
 {
   cstart = pos + 1;
   maybeErrSlashInEndTag(selfClosing);
-  stateSave = NS_HTML5TOKENIZER_DATA;
+  stateSave = nsHtml5Tokenizer::DATA;
   nsHtml5HtmlAttributes* attrs = (!attributes ? nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES : attributes);
   if (endTag) {
     maybeErrAttributesOnEndTag(attrs);
     if (!viewingXmlSource) {
       tokenHandler->endTag(tagName);
     }
     if (newAttributesEachTime) {
       delete attributes;
@@ -407,33 +407,33 @@ nsHtml5Tokenizer::tokenizeBuffer(nsHtml5
   int32_t returnState = returnStateSave;
   char16_t c = '\0';
   shouldSuspend = false;
   lastCR = false;
   int32_t start = buffer->getStart();
   int32_t end = buffer->getEnd();
   int32_t pos = start - 1;
   switch(state) {
-    case NS_HTML5TOKENIZER_DATA:
-    case NS_HTML5TOKENIZER_RCDATA:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA:
-    case NS_HTML5TOKENIZER_PLAINTEXT:
-    case NS_HTML5TOKENIZER_RAWTEXT:
-    case NS_HTML5TOKENIZER_CDATA_SECTION:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:
-    case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END: {
+    case DATA:
+    case RCDATA:
+    case SCRIPT_DATA:
+    case PLAINTEXT:
+    case RAWTEXT:
+    case CDATA_SECTION:
+    case SCRIPT_DATA_ESCAPED:
+    case SCRIPT_DATA_ESCAPE_START:
+    case SCRIPT_DATA_ESCAPE_START_DASH:
+    case SCRIPT_DATA_ESCAPED_DASH:
+    case SCRIPT_DATA_ESCAPED_DASH_DASH:
+    case SCRIPT_DATA_DOUBLE_ESCAPE_START:
+    case SCRIPT_DATA_DOUBLE_ESCAPED:
+    case SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:
+    case SCRIPT_DATA_DOUBLE_ESCAPED_DASH:
+    case SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:
+    case SCRIPT_DATA_DOUBLE_ESCAPE_END: {
       cstart = start;
       break;
     }
     default: {
       cstart = INT32_MAX;
       break;
     }
   }
@@ -453,39 +453,44 @@ nsHtml5Tokenizer::tokenizeBuffer(nsHtml5
 }
 
 template<class P>
 int32_t 
 nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* buf, bool reconsume, int32_t returnState, int32_t endPos)
 {
   stateloop: for (; ; ) {
     switch(state) {
-      case NS_HTML5TOKENIZER_DATA: {
+      case DATA: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '&': {
               flushChars(buf, pos);
               MOZ_ASSERT(!charRefBufLen, "charRefBufLen not reset after previous use!");
               appendCharRefBuf(c);
               setAdditionalAndRememberAmpersandLocation('\0');
               returnState = state;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '<': {
               flushChars(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_OPEN, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::TAG_OPEN, reconsume, pos);
               NS_HTML5_BREAK(dataloop);
             }
             case '\0': {
               emitReplacementCharacter(buf, pos);
               continue;
             }
             case '\r': {
               emitCarriageReturn(buf, pos);
@@ -496,108 +501,129 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               continue;
             }
           }
         }
         dataloop_end: ;
       }
-      case NS_HTML5TOKENIZER_TAG_OPEN: {
+      case TAG_OPEN: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           if (c >= 'A' && c <= 'Z') {
             endTag = false;
             clearStrBufBeforeUse();
             appendStrBuf((char16_t) (c + 0x20));
             containsHyphen = false;
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::TAG_NAME, reconsume, pos);
             NS_HTML5_BREAK(tagopenloop);
           } else if (c >= 'a' && c <= 'z') {
             endTag = false;
             clearStrBufBeforeUse();
             appendStrBuf(c);
             containsHyphen = false;
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::TAG_NAME, reconsume, pos);
             NS_HTML5_BREAK(tagopenloop);
           }
           switch(c) {
             case '!': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::MARKUP_DECLARATION_OPEN,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '/': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_CLOSE_TAG_OPEN, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::CLOSE_TAG_OPEN, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\?': {
               if (viewingXmlSource) {
-                state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION, reconsume, pos);
+                state = P::transition(mViewSource,
+                                      nsHtml5Tokenizer::PROCESSING_INSTRUCTION,
+                                      reconsume,
+                                      pos);
                 NS_HTML5_CONTINUE(stateloop);
               }
               if (P::reportErrors) {
                 errProcessingInstruction();
               }
               clearStrBufBeforeUse();
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               if (P::reportErrors) {
                 errLtGt();
               }
               tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 2);
               cstart = pos + 1;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               if (P::reportErrors) {
                 errBadCharAfterLt(c);
               }
               tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
               cstart = pos;
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         tagopenloop_end: ;
       }
-      case NS_HTML5TOKENIZER_TAG_NAME: {
+      case TAG_NAME: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
               strBufToElementNameString();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f': {
               strBufToElementNameString();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(tagnameloop);
             }
             case '/': {
               strBufToElementNameString();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               strBufToElementNameString();
               state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
               if (shouldSuspend) {
                 NS_HTML5_BREAK(stateloop);
               }
@@ -614,17 +640,17 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
               }
               appendStrBuf(c);
               continue;
             }
           }
         }
         tagnameloop_end: ;
       }
-      case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME: {
+      case BEFORE_ATTRIBUTE_NAME: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
@@ -638,17 +664,20 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f': {
               continue;
             }
             case '/': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
               if (shouldSuspend) {
                 NS_HTML5_BREAK(stateloop);
               }
               NS_HTML5_CONTINUE(stateloop);
@@ -666,55 +695,68 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               if (c >= 'A' && c <= 'Z') {
                 c += 0x20;
               }
               attributeLine = line;
               clearStrBufBeforeUse();
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_NAME, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::ATTRIBUTE_NAME, reconsume, pos);
               NS_HTML5_BREAK(beforeattributenameloop);
             }
           }
         }
         beforeattributenameloop_end: ;
       }
-      case NS_HTML5TOKENIZER_ATTRIBUTE_NAME: {
+      case ATTRIBUTE_NAME: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
               attributeNameComplete();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::AFTER_ATTRIBUTE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f': {
               attributeNameComplete();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::AFTER_ATTRIBUTE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '/': {
               attributeNameComplete();
               addAttributeWithoutValue();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '=': {
               attributeNameComplete();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_ATTRIBUTE_VALUE,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(attributenameloop);
             }
             case '>': {
               attributeNameComplete();
               addAttributeWithoutValue();
               state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
               if (shouldSuspend) {
                 NS_HTML5_BREAK(stateloop);
@@ -737,17 +779,17 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
               }
               appendStrBuf(c);
               continue;
             }
           }
         }
         attributenameloop_end: ;
       }
-      case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE: {
+      case BEFORE_ATTRIBUTE_VALUE: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
@@ -759,31 +801,42 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             case ' ':
             case '\t':
             case '\f': {
               continue;
             }
             case '\"': {
               attributeLine = line;
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::ATTRIBUTE_VALUE_DOUBLE_QUOTED,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(beforeattributevalueloop);
             }
             case '&': {
               attributeLine = line;
               clearStrBufBeforeUse();
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::ATTRIBUTE_VALUE_UNQUOTED,
+                                    reconsume,
+                                    pos);
 
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\'': {
               attributeLine = line;
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::ATTRIBUTE_VALUE_SINGLE_QUOTED,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               if (P::reportErrors) {
                 errAttributeValueMissing();
               }
               addAttributeWithoutValue();
               state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
@@ -801,46 +854,57 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
               if (P::reportErrors) {
                 errLtOrEqualsOrGraveInUnquotedAttributeOrNull(c);
               }
             }
             default: {
               attributeLine = line;
               clearStrBufBeforeUse();
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::ATTRIBUTE_VALUE_UNQUOTED,
+                                    reconsume,
+                                    pos);
 
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         beforeattributevalueloop_end: ;
       }
-      case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
+      case ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '\"': {
               addAttributeWithValue();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::AFTER_ATTRIBUTE_VALUE_QUOTED,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(attributevaluedoublequotedloop);
             }
             case '&': {
               MOZ_ASSERT(!charRefBufLen, "charRefBufLen not reset after previous use!");
               appendCharRefBuf(c);
               setAdditionalAndRememberAmpersandLocation('\"');
               returnState = state;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
@@ -852,61 +916,73 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             default: {
               appendStrBuf(c);
               continue;
             }
           }
         }
         attributevaluedoublequotedloop_end: ;
       }
-      case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED: {
+      case AFTER_ATTRIBUTE_VALUE_QUOTED: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '/': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(afterattributevaluequotedloop);
             }
             case '>': {
               state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
               if (shouldSuspend) {
                 NS_HTML5_BREAK(stateloop);
               }
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               if (P::reportErrors) {
                 errNoSpaceBetweenAttributes();
               }
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         afterattributevaluequotedloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG: {
+      case SELF_CLOSING_START_TAG: {
         if (++pos == endPos) {
           NS_HTML5_BREAK(stateloop);
         }
         c = checkChar(buf, pos);
         switch(c) {
           case '>': {
             state = P::transition(mViewSource, emitCurrentTagToken(true, pos), reconsume, pos);
             if (shouldSuspend) {
@@ -914,54 +990,67 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             NS_HTML5_CONTINUE(stateloop);
           }
           default: {
             if (P::reportErrors) {
               errSlashNotFollowedByGt();
             }
             reconsume = true;
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
+            state = P::transition(mViewSource,
+                                  nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
+                                  reconsume,
+                                  pos);
             NS_HTML5_CONTINUE(stateloop);
           }
         }
       }
-      case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED: {
+      case ATTRIBUTE_VALUE_UNQUOTED: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '\r': {
               silentCarriageReturn();
               addAttributeWithValue();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f': {
               addAttributeWithValue();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '&': {
               MOZ_ASSERT(!charRefBufLen, "charRefBufLen not reset after previous use!");
               appendCharRefBuf(c);
               setAdditionalAndRememberAmpersandLocation('>');
               returnState = state;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               addAttributeWithValue();
               state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
               if (shouldSuspend) {
                 NS_HTML5_BREAK(stateloop);
               }
@@ -982,17 +1071,17 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             default: {
 
               appendStrBuf(c);
               continue;
             }
           }
         }
       }
-      case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME: {
+      case AFTER_ATTRIBUTE_NAME: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
@@ -1003,21 +1092,27 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             case ' ':
             case '\t':
             case '\f': {
               continue;
             }
             case '/': {
               addAttributeWithoutValue();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '=': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_ATTRIBUTE_VALUE,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               addAttributeWithoutValue();
               state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
               if (shouldSuspend) {
                 NS_HTML5_BREAK(stateloop);
               }
@@ -1035,144 +1130,165 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               addAttributeWithoutValue();
               if (c >= 'A' && c <= 'Z') {
                 c += 0x20;
               }
               clearStrBufBeforeUse();
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_NAME, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::ATTRIBUTE_NAME, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
       }
-      case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN: {
+      case MARKUP_DECLARATION_OPEN: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '-': {
               clearStrBufBeforeUse();
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::MARKUP_DECLARATION_HYPHEN,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(markupdeclarationopenloop);
             }
             case 'd':
             case 'D': {
               clearStrBufBeforeUse();
               appendStrBuf(c);
               index = 0;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::MARKUP_DECLARATION_OCTYPE,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '[': {
               if (tokenHandler->cdataSectionAllowed()) {
                 clearStrBufBeforeUse();
                 appendStrBuf(c);
                 index = 0;
-                state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_START, reconsume, pos);
+                state = P::transition(
+                  mViewSource, nsHtml5Tokenizer::CDATA_START, reconsume, pos);
                 NS_HTML5_CONTINUE(stateloop);
               }
             }
             default: {
               if (P::reportErrors) {
                 errBogusComment();
               }
               clearStrBufBeforeUse();
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         markupdeclarationopenloop_end: ;
       }
-      case NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN: {
+      case MARKUP_DECLARATION_HYPHEN: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\0': {
               NS_HTML5_BREAK(stateloop);
             }
             case '-': {
               clearStrBufAfterOneHyphen();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_START, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT_START, reconsume, pos);
               NS_HTML5_BREAK(markupdeclarationhyphenloop);
             }
             default: {
               if (P::reportErrors) {
                 errBogusComment();
               }
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         markupdeclarationhyphenloop_end: ;
       }
-      case NS_HTML5TOKENIZER_COMMENT_START: {
+      case COMMENT_START: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '-': {
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_START_DASH, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::COMMENT_START_DASH,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               if (P::reportErrors) {
                 errPrematureEndOfComment();
               }
               emitComment(0, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
               NS_HTML5_BREAK(commentstartloop);
             }
             case '\0': {
               c = 0xfffd;
             }
             default: {
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
               NS_HTML5_BREAK(commentstartloop);
             }
           }
         }
         commentstartloop_end: ;
       }
-      case NS_HTML5TOKENIZER_COMMENT: {
+      case COMMENT: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '-': {
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_DASH, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::COMMENT_END_DASH,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(commentloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
@@ -1184,213 +1300,237 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             default: {
               appendStrBuf(c);
               continue;
             }
           }
         }
         commentloop_end: ;
       }
-      case NS_HTML5TOKENIZER_COMMENT_END_DASH: {
+      case COMMENT_END_DASH: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '-': {
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT_END, reconsume, pos);
               NS_HTML5_BREAK(commentenddashloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\0': {
               c = 0xfffd;
             }
             default: {
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         commentenddashloop_end: ;
       }
-      case NS_HTML5TOKENIZER_COMMENT_END: {
+      case COMMENT_END: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '>': {
               emitComment(2, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '-': {
               adjustDoubleHyphenAndAppendToStrBufAndErr(c);
               continue;
             }
             case '\r': {
               adjustDoubleHyphenAndAppendToStrBufCarriageReturn();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               adjustDoubleHyphenAndAppendToStrBufLineFeed();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '!': {
               if (P::reportErrors) {
                 errHyphenHyphenBang();
               }
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_BANG, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::COMMENT_END_BANG,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\0': {
               c = 0xfffd;
             }
             default: {
               adjustDoubleHyphenAndAppendToStrBufAndErr(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
 
       }
-      case NS_HTML5TOKENIZER_COMMENT_END_BANG: {
+      case COMMENT_END_BANG: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '>': {
               emitComment(3, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '-': {
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END_DASH, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::COMMENT_END_DASH,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
               continue;
             }
             case '\0': {
               c = 0xfffd;
             }
             default: {
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
       }
-      case NS_HTML5TOKENIZER_COMMENT_START_DASH: {
+      case COMMENT_START_DASH: {
         if (++pos == endPos) {
           NS_HTML5_BREAK(stateloop);
         }
         c = checkChar(buf, pos);
         switch(c) {
           case '-': {
             appendStrBuf(c);
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT_END, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::COMMENT_END, reconsume, pos);
             NS_HTML5_CONTINUE(stateloop);
           }
           case '>': {
             if (P::reportErrors) {
               errPrematureEndOfComment();
             }
             emitComment(1, pos);
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
             NS_HTML5_CONTINUE(stateloop);
           }
           case '\r': {
             appendStrBufCarriageReturn();
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
             NS_HTML5_BREAK(stateloop);
           }
           case '\n': {
             appendStrBufLineFeed();
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
             NS_HTML5_CONTINUE(stateloop);
           }
           case '\0': {
             c = 0xfffd;
           }
           default: {
             appendStrBuf(c);
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_COMMENT, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::COMMENT, reconsume, pos);
             NS_HTML5_CONTINUE(stateloop);
           }
         }
       }
-      case NS_HTML5TOKENIZER_CDATA_START: {
+      case CDATA_START: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           if (index < 6) {
             if (c == nsHtml5Tokenizer::CDATA_LSQB[index]) {
               appendStrBuf(c);
             } else {
               if (P::reportErrors) {
                 errBogusComment();
               }
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             index++;
             continue;
           } else {
             clearStrBufAfterUse();
             cstart = pos;
             reconsume = true;
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::CDATA_SECTION, reconsume, pos);
             break;
           }
         }
       }
-      case NS_HTML5TOKENIZER_CDATA_SECTION: {
+      case CDATA_SECTION: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case ']': {
               flushChars(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_RSQB, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::CDATA_RSQB, reconsume, pos);
               NS_HTML5_BREAK(cdatasectionloop);
             }
             case '\0': {
               emitReplacementCharacter(buf, pos);
               continue;
             }
             case '\r': {
               emitCarriageReturn(buf, pos);
@@ -1401,87 +1541,99 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               continue;
             }
           }
         }
         cdatasectionloop_end: ;
       }
-      case NS_HTML5TOKENIZER_CDATA_RSQB: {
+      case CDATA_RSQB: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case ']': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_RSQB_RSQB, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::CDATA_RSQB_RSQB, reconsume, pos);
               NS_HTML5_BREAK(cdatarsqb);
             }
             default: {
               tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1);
               cstart = pos;
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::CDATA_SECTION, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         cdatarsqb_end: ;
       }
-      case NS_HTML5TOKENIZER_CDATA_RSQB_RSQB: {
+      case CDATA_RSQB_RSQB: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case ']': {
               tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1);
               continue;
             }
             case '>': {
               cstart = pos + 1;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 2);
               cstart = pos;
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_CDATA_SECTION, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::CDATA_SECTION, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
 
       }
-      case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED: {
+      case ATTRIBUTE_VALUE_SINGLE_QUOTED: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '\'': {
               addAttributeWithValue();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::AFTER_ATTRIBUTE_VALUE_QUOTED,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '&': {
               MOZ_ASSERT(!charRefBufLen, "charRefBufLen not reset after previous use!");
               appendCharRefBuf(c);
               setAdditionalAndRememberAmpersandLocation('\'');
               returnState = state;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(attributevaluesinglequotedloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
@@ -1493,43 +1645,44 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             default: {
               appendStrBuf(c);
               continue;
             }
           }
         }
         attributevaluesinglequotedloop_end: ;
       }
-      case NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE: {
+      case CONSUME_CHARACTER_REFERENCE: {
         if (++pos == endPos) {
           NS_HTML5_BREAK(stateloop);
         }
         c = checkChar(buf, pos);
         if (c == '\0') {
           NS_HTML5_BREAK(stateloop);
         }
         switch(c) {
           case ' ':
           case '\t':
           case '\n':
           case '\r':
           case '\f':
           case '<':
           case '&': {
             emitOrAppendCharRefBuf(returnState);
-            if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+            if (!(returnState & DATA_AND_RCDATA_MASK)) {
               cstart = pos;
             }
             reconsume = true;
             state = P::transition(mViewSource, returnState, reconsume, pos);
             NS_HTML5_CONTINUE(stateloop);
           }
           case '#': {
             appendCharRefBuf('#');
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_NCR, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::CONSUME_NCR, reconsume, pos);
             NS_HTML5_CONTINUE(stateloop);
           }
           default: {
             if (c == additional) {
               emitOrAppendCharRefBuf(returnState);
               reconsume = true;
               state = P::transition(mViewSource, returnState, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
@@ -1538,29 +1691,33 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
               firstCharKey = c - 'a' + 26;
             } else if (c >= 'A' && c <= 'Z') {
               firstCharKey = c - 'A';
             } else {
               if (P::reportErrors) {
                 errNoNamedCharacterMatch();
               }
               emitOrAppendCharRefBuf(returnState);
-              if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+              if (!(returnState & DATA_AND_RCDATA_MASK)) {
                 cstart = pos;
               }
               reconsume = true;
               state = P::transition(mViewSource, returnState, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             appendCharRefBuf(c);
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP, reconsume, pos);
+            state =
+              P::transition(mViewSource,
+                            nsHtml5Tokenizer::CHARACTER_REFERENCE_HILO_LOOKUP,
+                            reconsume,
+                            pos);
           }
         }
       }
-      case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP: {
+      case CHARACTER_REFERENCE_HILO_LOOKUP: {
         {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           if (c == '\0') {
             NS_HTML5_BREAK(stateloop);
           }
@@ -1571,33 +1728,36 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
               hilo = row[firstCharKey];
             }
           }
           if (!hilo) {
             if (P::reportErrors) {
               errNoNamedCharacterMatch();
             }
             emitOrAppendCharRefBuf(returnState);
-            if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+            if (!(returnState & DATA_AND_RCDATA_MASK)) {
               cstart = pos;
             }
             reconsume = true;
             state = P::transition(mViewSource, returnState, reconsume, pos);
             NS_HTML5_CONTINUE(stateloop);
           }
           appendCharRefBuf(c);
           lo = hilo & 0xFFFF;
           hi = hilo >> 16;
           entCol = -1;
           candidate = -1;
           charRefBufMark = 0;
-          state = P::transition(mViewSource, NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL, reconsume, pos);
+          state = P::transition(mViewSource,
+                                nsHtml5Tokenizer::CHARACTER_REFERENCE_TAIL,
+                                reconsume,
+                                pos);
         }
       }
-      case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL: {
+      case CHARACTER_REFERENCE_TAIL: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           if (c == '\0') {
             NS_HTML5_BREAK(stateloop);
           }
@@ -1649,43 +1809,43 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
           continue;
         }
         outer_end: ;
         if (candidate == -1) {
           if (P::reportErrors) {
             errNoNamedCharacterMatch();
           }
           emitOrAppendCharRefBuf(returnState);
-          if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+          if (!(returnState & DATA_AND_RCDATA_MASK)) {
             cstart = pos;
           }
           reconsume = true;
           state = P::transition(mViewSource, returnState, reconsume, pos);
           NS_HTML5_CONTINUE(stateloop);
         } else {
           const nsHtml5CharacterName& candidateName = nsHtml5NamedCharacters::NAMES[candidate];
           if (!candidateName.length() || candidateName.charAt(candidateName.length() - 1) != ';') {
-            if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+            if ((returnState & DATA_AND_RCDATA_MASK)) {
               char16_t ch;
               if (charRefBufMark == charRefBufLen) {
                 ch = c;
               } else {
                 ch = charRefBuf[charRefBufMark];
               }
               if (ch == '=' || (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
                 if (P::reportErrors) {
                   errNoNamedCharacterMatch();
                 }
                 appendCharRefBufToStrBuf();
                 reconsume = true;
                 state = P::transition(mViewSource, returnState, reconsume, pos);
                 NS_HTML5_CONTINUE(stateloop);
               }
             }
-            if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+            if ((returnState & DATA_AND_RCDATA_MASK)) {
               if (P::reportErrors) {
                 errUnescapedAmpersandInterpretedAsCharacterReference();
               }
             } else {
               if (P::reportErrors) {
                 errNotSemicolonTerminated();
               }
             }
@@ -1693,53 +1853,55 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
           P::completedNamedCharacterReference(mViewSource);
           const char16_t* val = nsHtml5NamedCharacters::VALUES[candidate];
           if (!val[1]) {
             emitOrAppendOne(val, returnState);
           } else {
             emitOrAppendTwo(val, returnState);
           }
           if (charRefBufMark < charRefBufLen) {
-            if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+            if ((returnState & DATA_AND_RCDATA_MASK)) {
               appendStrBuf(charRefBuf, charRefBufMark, charRefBufLen - charRefBufMark);
             } else {
               tokenHandler->characters(charRefBuf, charRefBufMark, charRefBufLen - charRefBufMark);
             }
           }
           bool earlyBreak = (c == ';' && charRefBufMark == charRefBufLen);
           charRefBufLen = 0;
-          if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+          if (!(returnState & DATA_AND_RCDATA_MASK)) {
             cstart = earlyBreak ? pos + 1 : pos;
           }
           reconsume = !earlyBreak;
           state = P::transition(mViewSource, returnState, reconsume, pos);
           NS_HTML5_CONTINUE(stateloop);
         }
       }
-      case NS_HTML5TOKENIZER_CONSUME_NCR: {
+      case CONSUME_NCR: {
         if (++pos == endPos) {
           NS_HTML5_BREAK(stateloop);
         }
         c = checkChar(buf, pos);
         value = 0;
         seenDigits = false;
         switch(c) {
           case 'x':
           case 'X': {
             appendCharRefBuf(c);
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_HEX_NCR_LOOP, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::HEX_NCR_LOOP, reconsume, pos);
             NS_HTML5_CONTINUE(stateloop);
           }
           default: {
             reconsume = true;
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::DECIMAL_NRC_LOOP, reconsume, pos);
           }
         }
       }
-      case NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP: {
+      case DECIMAL_NRC_LOOP: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
@@ -1749,67 +1911,73 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             seenDigits = true;
             if (value <= 0x10FFFF) {
               value *= 10;
               value += c - '0';
             }
             continue;
           } else if (c == ';') {
             if (seenDigits) {
-              if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+              if (!(returnState & DATA_AND_RCDATA_MASK)) {
                 cstart = pos + 1;
               }
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::HANDLE_NCR_VALUE,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(decimalloop);
             } else {
               if (P::reportErrors) {
                 errNoDigitsInNCR();
               }
               appendCharRefBuf(';');
               emitOrAppendCharRefBuf(returnState);
-              if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+              if (!(returnState & DATA_AND_RCDATA_MASK)) {
                 cstart = pos + 1;
               }
               state = P::transition(mViewSource, returnState, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           } else {
             if (!seenDigits) {
               if (P::reportErrors) {
                 errNoDigitsInNCR();
               }
               emitOrAppendCharRefBuf(returnState);
-              if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+              if (!(returnState & DATA_AND_RCDATA_MASK)) {
                 cstart = pos;
               }
               reconsume = true;
               state = P::transition(mViewSource, returnState, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             } else {
               if (P::reportErrors) {
                 errCharRefLacksSemicolon();
               }
-              if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+              if (!(returnState & DATA_AND_RCDATA_MASK)) {
                 cstart = pos;
               }
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::HANDLE_NCR_VALUE,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(decimalloop);
             }
           }
         }
         decimalloop_end: ;
       }
-      case NS_HTML5TOKENIZER_HANDLE_NCR_VALUE: {
+      case HANDLE_NCR_VALUE: {
         charRefBufLen = 0;
         handleNcrValue(returnState);
         state = P::transition(mViewSource, returnState, reconsume, pos);
         NS_HTML5_CONTINUE(stateloop);
       }
-      case NS_HTML5TOKENIZER_HEX_NCR_LOOP: {
+      case HEX_NCR_LOOP: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           MOZ_ASSERT(value >= 0, "value must not become negative.");
           if (c >= '0' && c <= '9') {
             seenDigits = true;
@@ -1829,60 +1997,66 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             seenDigits = true;
             if (value <= 0x10FFFF) {
               value *= 16;
               value += c - 'a' + 10;
             }
             continue;
           } else if (c == ';') {
             if (seenDigits) {
-              if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+              if (!(returnState & DATA_AND_RCDATA_MASK)) {
                 cstart = pos + 1;
               }
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::HANDLE_NCR_VALUE,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             } else {
               if (P::reportErrors) {
                 errNoDigitsInNCR();
               }
               appendCharRefBuf(';');
               emitOrAppendCharRefBuf(returnState);
-              if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+              if (!(returnState & DATA_AND_RCDATA_MASK)) {
                 cstart = pos + 1;
               }
               state = P::transition(mViewSource, returnState, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           } else {
             if (!seenDigits) {
               if (P::reportErrors) {
                 errNoDigitsInNCR();
               }
               emitOrAppendCharRefBuf(returnState);
-              if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+              if (!(returnState & DATA_AND_RCDATA_MASK)) {
                 cstart = pos;
               }
               reconsume = true;
               state = P::transition(mViewSource, returnState, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             } else {
               if (P::reportErrors) {
                 errCharRefLacksSemicolon();
               }
-              if (!(returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+              if (!(returnState & DATA_AND_RCDATA_MASK)) {
                 cstart = pos;
               }
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_HANDLE_NCR_VALUE, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::HANDLE_NCR_VALUE,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
       }
-      case NS_HTML5TOKENIZER_PLAINTEXT: {
+      case PLAINTEXT: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
@@ -1901,100 +2075,113 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               continue;
             }
           }
         }
 
       }
-      case NS_HTML5TOKENIZER_CLOSE_TAG_OPEN: {
+      case CLOSE_TAG_OPEN: {
         if (++pos == endPos) {
           NS_HTML5_BREAK(stateloop);
         }
         c = checkChar(buf, pos);
         switch(c) {
           case '>': {
             if (P::reportErrors) {
               errLtSlashGt();
             }
             cstart = pos + 1;
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
             NS_HTML5_CONTINUE(stateloop);
           }
           case '\r': {
             silentCarriageReturn();
             if (P::reportErrors) {
               errGarbageAfterLtSlash();
             }
             clearStrBufBeforeUse();
             appendStrBuf('\n');
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::BOGUS_COMMENT, reconsume, pos);
             NS_HTML5_BREAK(stateloop);
           }
           case '\n': {
             silentLineFeed();
             if (P::reportErrors) {
               errGarbageAfterLtSlash();
             }
             clearStrBufBeforeUse();
             appendStrBuf(c);
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::BOGUS_COMMENT, reconsume, pos);
             NS_HTML5_CONTINUE(stateloop);
           }
           case '\0': {
             c = 0xfffd;
           }
           default: {
             if (c >= 'A' && c <= 'Z') {
               c += 0x20;
             }
             if (c >= 'a' && c <= 'z') {
               endTag = true;
               clearStrBufBeforeUse();
               appendStrBuf(c);
               containsHyphen = false;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::TAG_NAME, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             } else {
               if (P::reportErrors) {
                 errGarbageAfterLtSlash();
               }
               clearStrBufBeforeUse();
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
       }
-      case NS_HTML5TOKENIZER_RCDATA: {
+      case RCDATA: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '&': {
               flushChars(buf, pos);
               MOZ_ASSERT(!charRefBufLen, "charRefBufLen not reset after previous use!");
               appendCharRefBuf(c);
               setAdditionalAndRememberAmpersandLocation('\0');
               returnState = state;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::CONSUME_CHARACTER_REFERENCE,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '<': {
               flushChars(buf, pos);
               returnState = state;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::RAWTEXT_RCDATA_LESS_THAN_SIGN,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\0': {
               emitReplacementCharacter(buf, pos);
               continue;
             }
             case '\r': {
               emitCarriageReturn(buf, pos);
@@ -2005,31 +2192,35 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               continue;
             }
           }
         }
 
       }
-      case NS_HTML5TOKENIZER_RAWTEXT: {
+      case RAWTEXT: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '<': {
               flushChars(buf, pos);
               returnState = state;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::RAWTEXT_RCDATA_LESS_THAN_SIGN,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(rawtextloop);
             }
             case '\0': {
               emitReplacementCharacter(buf, pos);
               continue;
             }
             case '\r': {
               emitCarriageReturn(buf, pos);
@@ -2040,41 +2231,44 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               continue;
             }
           }
         }
         rawtextloop_end: ;
       }
-      case NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN: {
+      case RAWTEXT_RCDATA_LESS_THAN_SIGN: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '/': {
               index = 0;
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::NON_DATA_END_TAG_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(rawtextrcdatalessthansignloop);
             }
             default: {
               tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
               cstart = pos;
               reconsume = true;
               state = P::transition(mViewSource, returnState, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         rawtextrcdatalessthansignloop_end: ;
       }
-      case NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME: {
+      case NON_DATA_END_TAG_NAME: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           if (index < endTagExpectationAsArray.length) {
             char16_t e = endTagExpectationAsArray[index];
             char16_t folded = c;
@@ -2094,32 +2288,41 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             continue;
           } else {
             endTag = true;
             tagName = endTagExpectation;
             switch(c) {
               case '\r': {
                 silentCarriageReturn();
                 clearStrBufAfterUse();
-                state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
+                state = P::transition(mViewSource,
+                                      nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
+                                      reconsume,
+                                      pos);
                 NS_HTML5_BREAK(stateloop);
               }
               case '\n': {
                 silentLineFeed();
               }
               case ' ':
               case '\t':
               case '\f': {
                 clearStrBufAfterUse();
-                state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME, reconsume, pos);
+                state = P::transition(mViewSource,
+                                      nsHtml5Tokenizer::BEFORE_ATTRIBUTE_NAME,
+                                      reconsume,
+                                      pos);
                 NS_HTML5_CONTINUE(stateloop);
               }
               case '/': {
                 clearStrBufAfterUse();
-                state = P::transition(mViewSource, NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG, reconsume, pos);
+                state = P::transition(mViewSource,
+                                      nsHtml5Tokenizer::SELF_CLOSING_START_TAG,
+                                      reconsume,
+                                      pos);
                 NS_HTML5_CONTINUE(stateloop);
               }
               case '>': {
                 clearStrBufAfterUse();
                 state = P::transition(mViewSource, emitCurrentTagToken(false, pos), reconsume, pos);
                 if (shouldSuspend) {
                   NS_HTML5_BREAK(stateloop);
                 }
@@ -2135,35 +2338,39 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
                 }
                 state = P::transition(mViewSource, returnState, reconsume, pos);
                 NS_HTML5_CONTINUE(stateloop);
               }
             }
           }
         }
       }
-      case NS_HTML5TOKENIZER_BOGUS_COMMENT: {
+      case BOGUS_COMMENT: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '>': {
               emitComment(0, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '-': {
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BOGUS_COMMENT_HYPHEN,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(boguscommentloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
@@ -2175,69 +2382,78 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             default: {
               appendStrBuf(c);
               continue;
             }
           }
         }
         boguscommentloop_end: ;
       }
-      case NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN: {
-        boguscommenthyphenloop: for (; ; ) {
+      case BOGUS_COMMENT_HYPHEN: {
+      boguscommenthyphenloop:
+        for (;;) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '>': {
               emitComment(0, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '-': {
               appendSecondHyphenToBogusComment();
               NS_HTML5_CONTINUE(boguscommenthyphenloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_COMMENT, reconsume, pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\0': {
               c = 0xfffd;
             }
             default: {
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
 
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA: {
+      case SCRIPT_DATA: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '<': {
               flushChars(buf, pos);
               returnState = state;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_LESS_THAN_SIGN,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(scriptdataloop);
             }
             case '\0': {
               emitReplacementCharacter(buf, pos);
               continue;
             }
             case '\r': {
               emitCarriageReturn(buf, pos);
@@ -2248,144 +2464,182 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               continue;
             }
           }
         }
         scriptdataloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN: {
+      case SCRIPT_DATA_LESS_THAN_SIGN: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '/': {
               index = 0;
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::NON_DATA_END_TAG_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '!': {
               tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
               cstart = pos;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPE_START,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(scriptdatalessthansignloop);
             }
             default: {
               tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
               cstart = pos;
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::SCRIPT_DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         scriptdatalessthansignloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START: {
+      case SCRIPT_DATA_ESCAPE_START: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '-': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_ESCAPE_START_DASH,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(scriptdataescapestartloop);
             }
             default: {
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::SCRIPT_DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         scriptdataescapestartloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH: {
+      case SCRIPT_DATA_ESCAPE_START_DASH: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '-': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_DASH_DASH,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(scriptdataescapestartdashloop);
             }
             default: {
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::SCRIPT_DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         scriptdataescapestartdashloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH: {
+      case SCRIPT_DATA_ESCAPED_DASH_DASH: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '-': {
               continue;
             }
             case '<': {
               flushChars(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::SCRIPT_DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\0': {
               emitReplacementCharacter(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(scriptdataescapeddashdashloop);
             }
             case '\r': {
               emitCarriageReturn(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             default: {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(scriptdataescapeddashdashloop);
             }
           }
         }
         scriptdataescapeddashdashloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED: {
+      case SCRIPT_DATA_ESCAPED: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '-': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_DASH,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(scriptdataescapedloop);
             }
             case '<': {
               flushChars(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\0': {
               emitReplacementCharacter(buf, pos);
               continue;
             }
             case '\r': {
               emitCarriageReturn(buf, pos);
@@ -2396,149 +2650,198 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               continue;
             }
           }
         }
         scriptdataescapedloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH: {
+      case SCRIPT_DATA_ESCAPED_DASH: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '-': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_DASH_DASH,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '<': {
               flushChars(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(scriptdataescapeddashloop);
             }
             case '\0': {
               emitReplacementCharacter(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\r': {
               emitCarriageReturn(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             default: {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         scriptdataescapeddashloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
+      case SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '/': {
               index = 0;
               clearStrBufBeforeUse();
-              returnState = NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME, reconsume, pos);
+              returnState = nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED;
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::NON_DATA_END_TAG_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case 'S':
             case 's': {
               tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
               cstart = pos;
               index = 1;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPE_START,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(scriptdataescapedlessthanloop);
             }
             default: {
               tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
               cstart = pos;
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         scriptdataescapedlessthanloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START: {
+      case SCRIPT_DATA_DOUBLE_ESCAPE_START: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           MOZ_ASSERT(index > 0);
           if (index < 6) {
             char16_t folded = c;
             if (c >= 'A' && c <= 'Z') {
               folded += 0x20;
             }
             if (folded != nsHtml5Tokenizer::SCRIPT_ARR[index]) {
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             index++;
             continue;
           }
           switch(c) {
             case '\r': {
               emitCarriageReturn(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f':
             case '/':
             case '>': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(scriptdatadoubleescapestartloop);
             }
             default: {
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         scriptdatadoubleescapestartloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED: {
+      case SCRIPT_DATA_DOUBLE_ESCAPED: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '-': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED_DASH,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(scriptdatadoubleescapedloop);
             }
             case '<': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\0': {
               emitReplacementCharacter(buf, pos);
               continue;
             }
             case '\r': {
               emitCarriageReturn(buf, pos);
@@ -2549,158 +2852,217 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               continue;
             }
           }
         }
         scriptdatadoubleescapedloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH: {
+      case SCRIPT_DATA_DOUBLE_ESCAPED_DASH: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '-': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(scriptdatadoubleescapeddashloop);
             }
             case '<': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\0': {
               emitReplacementCharacter(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\r': {
               emitCarriageReturn(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             default: {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         scriptdatadoubleescapeddashloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: {
+      case SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '-': {
               continue;
             }
             case '<': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(scriptdatadoubleescapeddashdashloop);
             }
             case '>': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::SCRIPT_DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\0': {
               emitReplacementCharacter(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\r': {
               emitCarriageReturn(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             default: {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         scriptdatadoubleescapeddashdashloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: {
+      case SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '/': {
               index = 0;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPE_END,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(scriptdatadoubleescapedlessthanloop);
             }
             default: {
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         scriptdatadoubleescapedlessthanloop_end: ;
       }
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END: {
+      case SCRIPT_DATA_DOUBLE_ESCAPE_END: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           if (index < 6) {
             char16_t folded = c;
             if (c >= 'A' && c <= 'Z') {
               folded += 0x20;
             }
             if (folded != nsHtml5Tokenizer::SCRIPT_ARR[index]) {
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             index++;
             continue;
           }
           switch(c) {
             case '\r': {
               emitCarriageReturn(buf, pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f':
             case '/':
             case '>': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::SCRIPT_DATA_ESCAPED,
+                                    reconsume,
+                                    pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::SCRIPT_DATA_DOUBLE_ESCAPED,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
 
       }
-      case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE: {
+      case MARKUP_DECLARATION_OCTYPE: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           if (index < 6) {
             char16_t folded = c;
             if (c >= 'A' && c <= 'Z') {
@@ -2708,68 +3070,79 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             if (folded == nsHtml5Tokenizer::OCTYPE[index]) {
               appendStrBuf(c);
             } else {
               if (P::reportErrors) {
                 errBogusComment();
               }
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_COMMENT, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_COMMENT, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             index++;
             continue;
           } else {
             reconsume = true;
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::DOCTYPE, reconsume, pos);
             NS_HTML5_BREAK(markupdeclarationdoctypeloop);
           }
         }
         markupdeclarationdoctypeloop_end: ;
       }
-      case NS_HTML5TOKENIZER_DOCTYPE: {
+      case DOCTYPE: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           initDoctypeFields();
           switch(c) {
             case '\r': {
               silentCarriageReturn();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_DOCTYPE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_DOCTYPE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(doctypeloop);
             }
             default: {
               if (P::reportErrors) {
                 errMissingSpaceBeforeDoctypeName();
               }
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::BEFORE_DOCTYPE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(doctypeloop);
             }
           }
         }
         doctypeloop_end: ;
       }
-      case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME: {
+      case BEFORE_DOCTYPE_NAME: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
@@ -2788,79 +3161,88 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
               continue;
             }
             case '>': {
               if (P::reportErrors) {
                 errNamelessDoctype();
               }
               forceQuirks = true;
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\0': {
               c = 0xfffd;
             }
             default: {
               if (c >= 'A' && c <= 'Z') {
                 c += 0x20;
               }
               clearStrBufBeforeUse();
               appendStrBuf(c);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_NAME, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DOCTYPE_NAME, reconsume, pos);
               NS_HTML5_BREAK(beforedoctypenameloop);
             }
           }
         }
         beforedoctypenameloop_end: ;
       }
-      case NS_HTML5TOKENIZER_DOCTYPE_NAME: {
+      case DOCTYPE_NAME: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
               strBufToDoctypeName();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::AFTER_DOCTYPE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f': {
               strBufToDoctypeName();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME, reconsume, pos);
+              state = P::transition(mViewSource,
+                                    nsHtml5Tokenizer::AFTER_DOCTYPE_NAME,
+                                    reconsume,
+                                    pos);
               NS_HTML5_BREAK(doctypenameloop);
             }
             case '>': {
               strBufToDoctypeName();
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\0': {
               c = 0xfffd;
             }
             default: {
               if (c >= 'A' && c <= 'Z') {
                 c += 0x0020;
               }
               appendStrBuf(c);
               continue;
             }
           }
         }
         doctypenameloop_end: ;
       }
-      case NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME: {
+      case AFTER_DOCTYPE_NAME: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
@@ -2871,127 +3253,154 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             case ' ':
             case '\t':
             case '\f': {
               continue;
             }
             case '>': {
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case 'p':
             case 'P': {
               index = 0;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_UBLIC, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DOCTYPE_UBLIC, reconsume, pos);
               NS_HTML5_BREAK(afterdoctypenameloop);
             }
             case 's':
             case 'S': {
               index = 0;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_YSTEM, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DOCTYPE_YSTEM, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               bogusDoctype();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_DOCTYPE, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         afterdoctypenameloop_end: ;
       }
-      case NS_HTML5TOKENIZER_DOCTYPE_UBLIC: {
+      case DOCTYPE_UBLIC: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           if (index < 5) {
             char16_t folded = c;
             if (c >= 'A' && c <= 'Z') {
               folded += 0x20;
             }
             if (folded != nsHtml5Tokenizer::UBLIC[index]) {
               bogusDoctype();
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_DOCTYPE, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             index++;
             continue;
           } else {
             reconsume = true;
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD, reconsume, pos);
+            state =
+              P::transition(mViewSource,
+                            nsHtml5Tokenizer::AFTER_DOCTYPE_PUBLIC_KEYWORD,
+                            reconsume,
+                            pos);
             NS_HTML5_BREAK(doctypeublicloop);
           }
         }
         doctypeublicloop_end: ;
       }
-      case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD: {
+      case AFTER_DOCTYPE_PUBLIC_KEYWORD: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '\r': {
               silentCarriageReturn();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::BEFORE_DOCTYPE_PUBLIC_IDENTIFIER,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::BEFORE_DOCTYPE_PUBLIC_IDENTIFIER,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(afterdoctypepublickeywordloop);
             }
             case '\"': {
               if (P::reportErrors) {
                 errNoSpaceBetweenDoctypePublicKeywordAndQuote();
               }
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\'': {
               if (P::reportErrors) {
                 errNoSpaceBetweenDoctypePublicKeywordAndQuote();
               }
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               if (P::reportErrors) {
                 errExpectedPublicId();
               }
               forceQuirks = true;
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               bogusDoctype();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_DOCTYPE, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         afterdoctypepublickeywordloop_end: ;
       }
-      case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
+      case BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
@@ -3002,62 +3411,77 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             case ' ':
             case '\t':
             case '\f': {
               continue;
             }
             case '\"': {
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(beforedoctypepublicidentifierloop);
             }
             case '\'': {
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               if (P::reportErrors) {
                 errExpectedPublicId();
               }
               forceQuirks = true;
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               bogusDoctype();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_DOCTYPE, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         beforedoctypepublicidentifierloop_end: ;
       }
-      case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: {
+      case DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\"': {
               publicIdentifier = strBufToString();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::AFTER_DOCTYPE_PUBLIC_IDENTIFIER,
+                              reconsume,
+                              pos);
               NS_HTML5_BREAK(doctypepublicidentifierdoublequotedloop);
             }
             case '>': {
               if (P::reportErrors) {
                 errGtInPublicId();
               }
               forceQuirks = true;
               publicIdentifier = strBufToString();
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
@@ -3069,68 +3493,86 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             default: {
               appendStrBuf(c);
               continue;
             }
           }
         }
         doctypepublicidentifierdoublequotedloop_end: ;
       }
-      case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER: {
+      case AFTER_DOCTYPE_PUBLIC_IDENTIFIER: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(afterdoctypepublicidentifierloop);
             }
             case '>': {
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\"': {
               if (P::reportErrors) {
                 errNoSpaceBetweenPublicAndSystemIds();
               }
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\'': {
               if (P::reportErrors) {
                 errNoSpaceBetweenPublicAndSystemIds();
               }
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               bogusDoctype();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_DOCTYPE, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         afterdoctypepublicidentifierloop_end: ;
       }
-      case NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
+      case BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
@@ -3141,58 +3583,73 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             case ' ':
             case '\t':
             case '\f': {
               continue;
             }
             case '>': {
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\"': {
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(betweendoctypepublicandsystemidentifiersloop);
             }
             case '\'': {
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               bogusDoctype();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_DOCTYPE, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         betweendoctypepublicandsystemidentifiersloop_end: ;
       }
-      case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: {
+      case DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\"': {
               systemIdentifier = strBufToString();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::AFTER_DOCTYPE_SYSTEM_IDENTIFIER,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               if (P::reportErrors) {
                 errGtInSystemId();
               }
               forceQuirks = true;
               systemIdentifier = strBufToString();
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
@@ -3204,17 +3661,17 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             default: {
               appendStrBuf(c);
               continue;
             }
           }
         }
 
       }
-      case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
+      case AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
@@ -3225,144 +3682,170 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             case ' ':
             case '\t':
             case '\f': {
               continue;
             }
             case '>': {
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               bogusDoctypeWithoutQuirks();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_DOCTYPE, reconsume, pos);
               NS_HTML5_BREAK(afterdoctypesystemidentifierloop);
             }
           }
         }
         afterdoctypesystemidentifierloop_end: ;
       }
-      case NS_HTML5TOKENIZER_BOGUS_DOCTYPE: {
+      case BOGUS_DOCTYPE: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '>': {
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\r': {
               silentCarriageReturn();
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             default: {
               continue;
             }
           }
         }
       }
-      case NS_HTML5TOKENIZER_DOCTYPE_YSTEM: {
+      case DOCTYPE_YSTEM: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           if (index < 5) {
             char16_t folded = c;
             if (c >= 'A' && c <= 'Z') {
               folded += 0x20;
             }
             if (folded != nsHtml5Tokenizer::YSTEM[index]) {
               bogusDoctype();
               reconsume = true;
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_DOCTYPE, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             index++;
             NS_HTML5_CONTINUE(stateloop);
           } else {
             reconsume = true;
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD, reconsume, pos);
+            state =
+              P::transition(mViewSource,
+                            nsHtml5Tokenizer::AFTER_DOCTYPE_SYSTEM_KEYWORD,
+                            reconsume,
+                            pos);
             NS_HTML5_BREAK(doctypeystemloop);
           }
         }
         doctypeystemloop_end: ;
       }
-      case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD: {
+      case AFTER_DOCTYPE_SYSTEM_KEYWORD: {
         for (; ; ) {
           if (reconsume) {
             reconsume = false;
           } else {
             if (++pos == endPos) {
               NS_HTML5_BREAK(stateloop);
             }
             c = checkChar(buf, pos);
           }
           switch(c) {
             case '\r': {
               silentCarriageReturn();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::BEFORE_DOCTYPE_SYSTEM_IDENTIFIER,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               silentLineFeed();
             }
             case ' ':
             case '\t':
             case '\f': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::BEFORE_DOCTYPE_SYSTEM_IDENTIFIER,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(afterdoctypesystemkeywordloop);
             }
             case '\"': {
               if (P::reportErrors) {
                 errNoSpaceBetweenDoctypeSystemKeywordAndQuote();
               }
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\'': {
               if (P::reportErrors) {
                 errNoSpaceBetweenDoctypeSystemKeywordAndQuote();
               }
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               if (P::reportErrors) {
                 errExpectedPublicId();
               }
               forceQuirks = true;
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               bogusDoctype();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_DOCTYPE, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         afterdoctypesystemkeywordloop_end: ;
       }
-      case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: {
+      case BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\r': {
               silentCarriageReturn();
@@ -3373,62 +3856,77 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             case ' ':
             case '\t':
             case '\f': {
               continue;
             }
             case '\"': {
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\'': {
               clearStrBufBeforeUse();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(beforedoctypesystemidentifierloop);
             }
             case '>': {
               if (P::reportErrors) {
                 errExpectedSystemId();
               }
               forceQuirks = true;
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             default: {
               bogusDoctype();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_BOGUS_DOCTYPE, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::BOGUS_DOCTYPE, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
           }
         }
         beforedoctypesystemidentifierloop_end: ;
       }
-      case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
+      case DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\'': {
               systemIdentifier = strBufToString();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::AFTER_DOCTYPE_SYSTEM_IDENTIFIER,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               if (P::reportErrors) {
                 errGtInSystemId();
               }
               forceQuirks = true;
               systemIdentifier = strBufToString();
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
@@ -3439,36 +3937,41 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               appendStrBuf(c);
               continue;
             }
           }
         }
       }
-      case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
+      case DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\'': {
               publicIdentifier = strBufToString();
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER, reconsume, pos);
+              state =
+                P::transition(mViewSource,
+                              nsHtml5Tokenizer::AFTER_DOCTYPE_PUBLIC_IDENTIFIER,
+                              reconsume,
+                              pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '>': {
               if (P::reportErrors) {
                 errGtInPublicId();
               }
               forceQuirks = true;
               publicIdentifier = strBufToString();
               emitDoctypeToken(pos);
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+              state = P::transition(
+                mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
               NS_HTML5_CONTINUE(stateloop);
             }
             case '\r': {
               appendStrBufCarriageReturn();
               NS_HTML5_BREAK(stateloop);
             }
             case '\n': {
               appendStrBufLineFeed();
@@ -3479,46 +3982,54 @@ nsHtml5Tokenizer::stateLoop(int32_t stat
             }
             default: {
               appendStrBuf(c);
               continue;
             }
           }
         }
       }
-      case NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION: {
+      case PROCESSING_INSTRUCTION: {
         for (; ; ) {
           if (++pos == endPos) {
             NS_HTML5_BREAK(stateloop);
           }
           c = checkChar(buf, pos);
           switch(c) {
             case '\?': {
-              state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION_QUESTION_MARK, reconsume, pos);
+              state = P::transition(
+                mViewSource,
+                nsHtml5Tokenizer::PROCESSING_INSTRUCTION_QUESTION_MARK,
+                reconsume,
+                pos);
               NS_HTML5_BREAK(processinginstructionloop);
             }
             default: {
               continue;
             }
           }
         }
         processinginstructionloop_end: ;
       }
-      case NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION_QUESTION_MARK: {
+      case PROCESSING_INSTRUCTION_QUESTION_MARK: {
         if (++pos == endPos) {
           NS_HTML5_BREAK(stateloop);
         }
         c = checkChar(buf, pos);
         switch(c) {
           case '>': {
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_DATA, reconsume, pos);
+            state = P::transition(
+              mViewSource, nsHtml5Tokenizer::DATA, reconsume, pos);
             NS_HTML5_CONTINUE(stateloop);
           }
           default: {
-            state = P::transition(mViewSource, NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION, reconsume, pos);
+            state = P::transition(mViewSource,
+                                  nsHtml5Tokenizer::PROCESSING_INSTRUCTION,
+                                  reconsume,
+                                  pos);
             NS_HTML5_CONTINUE(stateloop);
           }
         }
       }
     }
   }
   stateloop_end: ;
   flushChars(buf, pos);
@@ -3603,100 +4114,100 @@ nsHtml5Tokenizer::handleNcrValue(int32_t
       errNcrSurrogate();
       emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState);
     } else {
       char16_t ch = (char16_t) value;
       bmpChar[0] = ch;
       emitOrAppendOne(bmpChar, returnState);
     }
   } else if (value <= 0x10FFFF) {
-    astralChar[0] = (char16_t) (NS_HTML5TOKENIZER_LEAD_OFFSET + (value >> 10));
+    astralChar[0] = (char16_t)(nsHtml5Tokenizer::LEAD_OFFSET + (value >> 10));
     astralChar[1] = (char16_t) (0xDC00 + (value & 0x3FF));
     emitOrAppendTwo(astralChar, returnState);
   } else {
     errNcrOutOfRange();
     emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState);
   }
 }
 
 void 
 nsHtml5Tokenizer::eof()
 {
   int32_t state = stateSave;
   int32_t returnState = returnStateSave;
   eofloop: for (; ; ) {
     switch(state) {
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN:
-      case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
+      case SCRIPT_DATA_LESS_THAN_SIGN:
+      case SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
         tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_TAG_OPEN: {
+      case TAG_OPEN: {
         errEofAfterLt();
         tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN: {
+      case RAWTEXT_RCDATA_LESS_THAN_SIGN: {
         tokenHandler->characters(nsHtml5Tokenizer::LT_GT, 0, 1);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME: {
+      case NON_DATA_END_TAG_NAME: {
         tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2);
         emitStrBuf();
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_CLOSE_TAG_OPEN: {
+      case CLOSE_TAG_OPEN: {
         errEofAfterLt();
         tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_TAG_NAME: {
+      case TAG_NAME: {
         errEofInTagName();
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME:
-      case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED:
-      case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG: {
+      case BEFORE_ATTRIBUTE_NAME:
+      case AFTER_ATTRIBUTE_VALUE_QUOTED:
+      case SELF_CLOSING_START_TAG: {
         errEofWithoutGt();
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_ATTRIBUTE_NAME: {
+      case ATTRIBUTE_NAME: {
         errEofInAttributeName();
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME:
-      case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE: {
+      case AFTER_ATTRIBUTE_NAME:
+      case BEFORE_ATTRIBUTE_VALUE: {
         errEofWithoutGt();
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED:
-      case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED:
-      case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED: {
+      case ATTRIBUTE_VALUE_DOUBLE_QUOTED:
+      case ATTRIBUTE_VALUE_SINGLE_QUOTED:
+      case ATTRIBUTE_VALUE_UNQUOTED: {
         errEofInAttributeValue();
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_BOGUS_COMMENT: {
+      case BOGUS_COMMENT: {
         emitComment(0, 0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN: {
+      case BOGUS_COMMENT_HYPHEN: {
         emitComment(0, 0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN: {
+      case MARKUP_DECLARATION_OPEN: {
         errBogusComment();
         emitComment(0, 0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN: {
+      case MARKUP_DECLARATION_HYPHEN: {
         errBogusComment();
         emitComment(0, 0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE: {
+      case MARKUP_DECLARATION_OCTYPE: {
         if (index < 6) {
           errBogusComment();
           emitComment(0, 0);
         } else {
           errEofInDoctype();
           doctypeName = nsHtml5Atoms::emptystring;
           if (systemIdentifier) {
             systemIdentifier.Release();
@@ -3707,109 +4218,109 @@ nsHtml5Tokenizer::eof()
             publicIdentifier = nullptr;
           }
           forceQuirks = true;
           emitDoctypeToken(0);
           NS_HTML5_BREAK(eofloop);
         }
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_COMMENT_START:
-      case NS_HTML5TOKENIZER_COMMENT: {
+      case COMMENT_START:
+      case COMMENT: {
         errEofInComment();
         emitComment(0, 0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_COMMENT_END: {
+      case COMMENT_END: {
         errEofInComment();
         emitComment(2, 0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_COMMENT_END_DASH:
-      case NS_HTML5TOKENIZER_COMMENT_START_DASH: {
+      case COMMENT_END_DASH:
+      case COMMENT_START_DASH: {
         errEofInComment();
         emitComment(1, 0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_COMMENT_END_BANG: {
+      case COMMENT_END_BANG: {
         errEofInComment();
         emitComment(3, 0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_DOCTYPE:
-      case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME: {
+      case DOCTYPE:
+      case BEFORE_DOCTYPE_NAME: {
         errEofInDoctype();
         forceQuirks = true;
         emitDoctypeToken(0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_DOCTYPE_NAME: {
+      case DOCTYPE_NAME: {
         errEofInDoctype();
         strBufToDoctypeName();
         forceQuirks = true;
         emitDoctypeToken(0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_DOCTYPE_UBLIC:
-      case NS_HTML5TOKENIZER_DOCTYPE_YSTEM:
-      case NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME:
-      case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD:
-      case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD:
-      case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
+      case DOCTYPE_UBLIC:
+      case DOCTYPE_YSTEM:
+      case AFTER_DOCTYPE_NAME:
+      case AFTER_DOCTYPE_PUBLIC_KEYWORD:
+      case AFTER_DOCTYPE_SYSTEM_KEYWORD:
+      case BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
         errEofInDoctype();
         forceQuirks = true;
         emitDoctypeToken(0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:
-      case NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
+      case DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:
+      case DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
         errEofInPublicId();
         forceQuirks = true;
         publicIdentifier = strBufToString();
         emitDoctypeToken(0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER:
-      case NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:
-      case NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
+      case AFTER_DOCTYPE_PUBLIC_IDENTIFIER:
+      case BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:
+      case BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
         errEofInDoctype();
         forceQuirks = true;
         emitDoctypeToken(0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:
-      case NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
+      case DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:
+      case DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
         errEofInSystemId();
         forceQuirks = true;
         systemIdentifier = strBufToString();
         emitDoctypeToken(0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
+      case AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
         errEofInDoctype();
         forceQuirks = true;
         emitDoctypeToken(0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_BOGUS_DOCTYPE: {
+      case BOGUS_DOCTYPE: {
         emitDoctypeToken(0);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE: {
+      case CONSUME_CHARACTER_REFERENCE: {
         emitOrAppendCharRefBuf(returnState);
         state = returnState;
         continue;
       }
-      case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP: {
+      case CHARACTER_REFERENCE_HILO_LOOKUP: {
         errNoNamedCharacterMatch();
         emitOrAppendCharRefBuf(returnState);
         state = returnState;
         continue;
       }
-      case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL: {
+      case CHARACTER_REFERENCE_TAIL: {
         for (; ; ) {
           char16_t c = '\0';
           entCol++;
           for (; ; ) {
             if (hi == -1) {
               NS_HTML5_BREAK(hiloop);
             }
             if (entCol == nsHtml5NamedCharacters::NAMES[hi].length()) {
@@ -3850,78 +4361,78 @@ nsHtml5Tokenizer::eof()
         if (candidate == -1) {
           errNoNamedCharacterMatch();
           emitOrAppendCharRefBuf(returnState);
           state = returnState;
           NS_HTML5_CONTINUE(eofloop);
         } else {
           const nsHtml5CharacterName& candidateName = nsHtml5NamedCharacters::NAMES[candidate];
           if (!candidateName.length() || candidateName.charAt(candidateName.length() - 1) != ';') {
-            if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+            if ((returnState & DATA_AND_RCDATA_MASK)) {
               char16_t ch;
               if (charRefBufMark == charRefBufLen) {
                 ch = '\0';
               } else {
                 ch = charRefBuf[charRefBufMark];
               }
               if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
                 errNoNamedCharacterMatch();
                 appendCharRefBufToStrBuf();
                 state = returnState;
                 NS_HTML5_CONTINUE(eofloop);
               }
             }
-            if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+            if ((returnState & DATA_AND_RCDATA_MASK)) {
               errUnescapedAmpersandInterpretedAsCharacterReference();
             } else {
               errNotSemicolonTerminated();
             }
           }
           const char16_t* val = nsHtml5NamedCharacters::VALUES[candidate];
           if (!val[1]) {
             emitOrAppendOne(val, returnState);
           } else {
             emitOrAppendTwo(val, returnState);
           }
           if (charRefBufMark < charRefBufLen) {
-            if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+            if ((returnState & DATA_AND_RCDATA_MASK)) {
               appendStrBuf(charRefBuf, charRefBufMark, charRefBufLen - charRefBufMark);
             } else {
               tokenHandler->characters(charRefBuf, charRefBufMark, charRefBufLen - charRefBufMark);
             }
           }
           charRefBufLen = 0;
           state = returnState;
           NS_HTML5_CONTINUE(eofloop);
         }
       }
-      case NS_HTML5TOKENIZER_CONSUME_NCR:
-      case NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP:
-      case NS_HTML5TOKENIZER_HEX_NCR_LOOP: {
+      case CONSUME_NCR:
+      case DECIMAL_NRC_LOOP:
+      case HEX_NCR_LOOP: {
         if (!seenDigits) {
           errNoDigitsInNCR();
           emitOrAppendCharRefBuf(returnState);
           state = returnState;
           continue;
         } else {
           errCharRefLacksSemicolon();
         }
         handleNcrValue(returnState);
         state = returnState;
         continue;
       }
-      case NS_HTML5TOKENIZER_CDATA_RSQB: {
+      case CDATA_RSQB: {
         tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 1);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_CDATA_RSQB_RSQB: {
+      case CDATA_RSQB_RSQB: {
         tokenHandler->characters(nsHtml5Tokenizer::RSQB_RSQB, 0, 2);
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TOKENIZER_DATA:
+      case DATA:
       default: {
         NS_HTML5_BREAK(eofloop);
       }
     }
   }
   eofloop_end: ;
   tokenHandler->eof();
   return;
@@ -3946,28 +4457,28 @@ nsHtml5Tokenizer::internalEncodingDeclar
     return encodingDeclarationHandler->internalEncodingDeclaration(internalCharset);
   }
   return false;
 }
 
 void 
 nsHtml5Tokenizer::emitOrAppendTwo(const char16_t* val, int32_t returnState)
 {
-  if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+  if ((returnState & DATA_AND_RCDATA_MASK)) {
     appendStrBuf(val[0]);
     appendStrBuf(val[1]);
   } else {
     tokenHandler->characters(val, 0, 2);
   }
 }
 
 void 
 nsHtml5Tokenizer::emitOrAppendOne(const char16_t* val, int32_t returnState)
 {
-  if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
+  if ((returnState & DATA_AND_RCDATA_MASK)) {
     appendStrBuf(val[0]);
   } else {
     tokenHandler->characters(val, 0, 1);
   }
 }
 
 void 
 nsHtml5Tokenizer::end()
@@ -3996,25 +4507,25 @@ void
 nsHtml5Tokenizer::requestSuspension()
 {
   shouldSuspend = true;
 }
 
 bool 
 nsHtml5Tokenizer::isInDataState()
 {
-  return (stateSave == NS_HTML5TOKENIZER_DATA);
+  return (stateSave == DATA);
 }
 
 void 
 nsHtml5Tokenizer::resetToDataState()
 {
   clearStrBufAfterUse();
   charRefBufLen = 0;
-  stateSave = NS_HTML5TOKENIZER_DATA;
+  stateSave = nsHtml5Tokenizer::DATA;
   lastCR = false;
   index = 0;
   forceQuirks = false;
   additional = '\0';
   entCol = -1;
   firstCharKey = -1;
   lo = 0;
   hi = 0;
@@ -4094,17 +4605,17 @@ nsHtml5Tokenizer::loadState(nsHtml5Token
   }
   if (!other->attributeName) {
     attributeName = nullptr;
   } else if (other->attributeName->isInterned()) {
     attributeName = other->attributeName;
   } else {
     nonInternedAttributeName->setNameForNonInterned(
       nsHtml5Portability::newLocalFromLocal(
-        other->attributeName->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML), interner));
+        other->attributeName->getLocal(nsHtml5AttributeName::HTML), interner));
     attributeName = nonInternedAttributeName;
   }
   delete attributes;
   if (!other->attributes) {
     attributes = nullptr;
   } else {
     attributes = other->attributes->cloneAttributes(interner);
   }
--- a/parser/html/nsHtml5Tokenizer.h
+++ b/parser/html/nsHtml5Tokenizer.h
@@ -44,28 +44,184 @@
 #include "nsHtml5Atoms.h"
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Macros.h"
 #include "nsHtml5Highlighter.h"
 #include "nsHtml5TokenizerLoopPolicies.h"
 
 class nsHtml5StreamParser;
 
+class nsHtml5AttributeName;
+class nsHtml5ElementName;
 class nsHtml5TreeBuilder;
 class nsHtml5MetaScanner;
-class nsHtml5AttributeName;
-class nsHtml5ElementName;
 class nsHtml5UTF16Buffer;
 class nsHtml5StateSnapshot;
 class nsHtml5Portability;
 
 
 class nsHtml5Tokenizer
 {
   private:
+    static const int32_t DATA_AND_RCDATA_MASK = ~1;
+
+  public:
+    static const int32_t DATA = 0;
+
+    static const int32_t RCDATA = 1;
+
+    static const int32_t SCRIPT_DATA = 2;
+
+    static const int32_t RAWTEXT = 3;
+
+    static const int32_t SCRIPT_DATA_ESCAPED = 4;
+
+    static const int32_t ATTRIBUTE_VALUE_DOUBLE_QUOTED = 5;
+
+    static const int32_t ATTRIBUTE_VALUE_SINGLE_QUOTED = 6;
+
+    static const int32_t ATTRIBUTE_VALUE_UNQUOTED = 7;
+
+    static const int32_t PLAINTEXT = 8;
+
+    static const int32_t TAG_OPEN = 9;
+
+    static const int32_t CLOSE_TAG_OPEN = 10;
+
+    static const int32_t TAG_NAME = 11;
+
+    static const int32_t BEFORE_ATTRIBUTE_NAME = 12;
+
+    static const int32_t ATTRIBUTE_NAME = 13;
+
+    static const int32_t AFTER_ATTRIBUTE_NAME = 14;
+
+    static const int32_t BEFORE_ATTRIBUTE_VALUE = 15;
+
+    static const int32_t AFTER_ATTRIBUTE_VALUE_QUOTED = 16;
+
+    static const int32_t BOGUS_COMMENT = 17;
+
+    static const int32_t MARKUP_DECLARATION_OPEN = 18;
+
+    static const int32_t DOCTYPE = 19;
+
+    static const int32_t BEFORE_DOCTYPE_NAME = 20;
+
+    static const int32_t DOCTYPE_NAME = 21;
+
+    static const int32_t AFTER_DOCTYPE_NAME = 22;
+
+    static const int32_t BEFORE_DOCTYPE_PUBLIC_IDENTIFIER = 23;
+
+    static const int32_t DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED = 24;
+
+    static const int32_t DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED = 25;
+
+    static const int32_t AFTER_DOCTYPE_PUBLIC_IDENTIFIER = 26;
+
+    static const int32_t BEFORE_DOCTYPE_SYSTEM_IDENTIFIER = 27;
+
+    static const int32_t DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED = 28;
+
+    static const int32_t DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED = 29;
+
+    static const int32_t AFTER_DOCTYPE_SYSTEM_IDENTIFIER = 30;
+
+    static const int32_t BOGUS_DOCTYPE = 31;
+
+    static const int32_t COMMENT_START = 32;
+
+    static const int32_t COMMENT_START_DASH = 33;
+
+    static const int32_t COMMENT = 34;
+
+    static const int32_t COMMENT_END_DASH = 35;
+
+    static const int32_t COMMENT_END = 36;
+
+    static const int32_t COMMENT_END_BANG = 37;
+
+    static const int32_t NON_DATA_END_TAG_NAME = 38;
+
+    static const int32_t MARKUP_DECLARATION_HYPHEN = 39;
+
+    static const int32_t MARKUP_DECLARATION_OCTYPE = 40;
+
+    static const int32_t DOCTYPE_UBLIC = 41;
+
+    static const int32_t DOCTYPE_YSTEM = 42;
+
+    static const int32_t AFTER_DOCTYPE_PUBLIC_KEYWORD = 43;
+
+    static const int32_t BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS = 44;
+
+    static const int32_t AFTER_DOCTYPE_SYSTEM_KEYWORD = 45;
+
+    static const int32_t CONSUME_CHARACTER_REFERENCE = 46;
+
+    static const int32_t CONSUME_NCR = 47;
+
+    static const int32_t CHARACTER_REFERENCE_TAIL = 48;
+
+    static const int32_t HEX_NCR_LOOP = 49;
+
+    static const int32_t DECIMAL_NRC_LOOP = 50;
+
+    static const int32_t HANDLE_NCR_VALUE = 51;
+
+    static const int32_t HANDLE_NCR_VALUE_RECONSUME = 52;
+
+    static const int32_t CHARACTER_REFERENCE_HILO_LOOKUP = 53;
+
+    static const int32_t SELF_CLOSING_START_TAG = 54;
+
+    static const int32_t CDATA_START = 55;
+
+    static const int32_t CDATA_SECTION = 56;
+
+    static const int32_t CDATA_RSQB = 57;
+
+    static const int32_t CDATA_RSQB_RSQB = 58;
+
+    static const int32_t SCRIPT_DATA_LESS_THAN_SIGN = 59;
+
+    static const int32_t SCRIPT_DATA_ESCAPE_START = 60;
+
+    static const int32_t SCRIPT_DATA_ESCAPE_START_DASH = 61;
+
+    static const int32_t SCRIPT_DATA_ESCAPED_DASH = 62;
+
+    static const int32_t SCRIPT_DATA_ESCAPED_DASH_DASH = 63;
+
+    static const int32_t BOGUS_COMMENT_HYPHEN = 64;
+
+    static const int32_t RAWTEXT_RCDATA_LESS_THAN_SIGN = 65;
+
+    static const int32_t SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN = 66;
+
+    static const int32_t SCRIPT_DATA_DOUBLE_ESCAPE_START = 67;
+
+    static const int32_t SCRIPT_DATA_DOUBLE_ESCAPED = 68;
+
+    static const int32_t SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN = 69;
+
+    static const int32_t SCRIPT_DATA_DOUBLE_ESCAPED_DASH = 70;
+
+    static const int32_t SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH = 71;
+
+    static const int32_t SCRIPT_DATA_DOUBLE_ESCAPE_END = 72;
+
+    static const int32_t PROCESSING_INSTRUCTION = 73;
+
+    static const int32_t PROCESSING_INSTRUCTION_QUESTION_MARK = 74;
+
+  private:
+    static const int32_t LEAD_OFFSET = (0xD800 - (0x10000 >> 10));
+
     static char16_t LT_GT[];
     static char16_t LT_SOLIDUS[];
     static char16_t RSQB_RSQB[];
     static char16_t REPLACEMENT_CHARACTER[];
     static char16_t LF[];
     static char16_t CDATA_LSQB[];
     static char16_t OCTYPE[];
     static char16_t UBLIC[];
@@ -301,89 +457,10 @@ class nsHtml5Tokenizer
     void setEncodingDeclarationHandler(nsHtml5StreamParser* encodingDeclarationHandler);
     ~nsHtml5Tokenizer();
     static void initializeStatics();
     static void releaseStatics();
 
 #include "nsHtml5TokenizerHSupplement.h"
 };
 
-#define NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK ~1
-#define NS_HTML5TOKENIZER_DATA 0
-#define NS_HTML5TOKENIZER_RCDATA 1
-#define NS_HTML5TOKENIZER_SCRIPT_DATA 2
-#define NS_HTML5TOKENIZER_RAWTEXT 3
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED 4
-#define NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED 5
-#define NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED 6
-#define NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED 7
-#define NS_HTML5TOKENIZER_PLAINTEXT 8
-#define NS_HTML5TOKENIZER_TAG_OPEN 9
-#define NS_HTML5TOKENIZER_CLOSE_TAG_OPEN 10
-#define NS_HTML5TOKENIZER_TAG_NAME 11
-#define NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME 12
-#define NS_HTML5TOKENIZER_ATTRIBUTE_NAME 13
-#define NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME 14
-#define NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE 15
-#define NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED 16
-#define NS_HTML5TOKENIZER_BOGUS_COMMENT 17
-#define NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN 18
-#define NS_HTML5TOKENIZER_DOCTYPE 19
-#define NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME 20
-#define NS_HTML5TOKENIZER_DOCTYPE_NAME 21
-#define NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME 22
-#define NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER 23
-#define NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED 24
-#define NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED 25
-#define NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER 26
-#define NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER 27
-#define NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED 28
-#define NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED 29
-#define NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER 30
-#define NS_HTML5TOKENIZER_BOGUS_DOCTYPE 31
-#define NS_HTML5TOKENIZER_COMMENT_START 32
-#define NS_HTML5TOKENIZER_COMMENT_START_DASH 33
-#define NS_HTML5TOKENIZER_COMMENT 34
-#define NS_HTML5TOKENIZER_COMMENT_END_DASH 35
-#define NS_HTML5TOKENIZER_COMMENT_END 36
-#define NS_HTML5TOKENIZER_COMMENT_END_BANG 37
-#define NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME 38
-#define NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN 39
-#define NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE 40
-#define NS_HTML5TOKENIZER_DOCTYPE_UBLIC 41
-#define NS_HTML5TOKENIZER_DOCTYPE_YSTEM 42
-#define NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_KEYWORD 43
-#define NS_HTML5TOKENIZER_BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS 44
-#define NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_KEYWORD 45
-#define NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE 46
-#define NS_HTML5TOKENIZER_CONSUME_NCR 47
-#define NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL 48
-#define NS_HTML5TOKENIZER_HEX_NCR_LOOP 49
-#define NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP 50
-#define NS_HTML5TOKENIZER_HANDLE_NCR_VALUE 51
-#define NS_HTML5TOKENIZER_HANDLE_NCR_VALUE_RECONSUME 52
-#define NS_HTML5TOKENIZER_CHARACTER_REFERENCE_HILO_LOOKUP 53
-#define NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG 54
-#define NS_HTML5TOKENIZER_CDATA_START 55
-#define NS_HTML5TOKENIZER_CDATA_SECTION 56
-#define NS_HTML5TOKENIZER_CDATA_RSQB 57
-#define NS_HTML5TOKENIZER_CDATA_RSQB_RSQB 58
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN 59
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START 60
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPE_START_DASH 61
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH 62
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH_DASH 63
-#define NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN 64
-#define NS_HTML5TOKENIZER_RAWTEXT_RCDATA_LESS_THAN_SIGN 65
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN 66
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_START 67
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED 68
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN 69
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH 70
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH 71
-#define NS_HTML5TOKENIZER_SCRIPT_DATA_DOUBLE_ESCAPE_END 72
-#define NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION 73
-#define NS_HTML5TOKENIZER_PROCESSING_INSTRUCTION_QUESTION_MARK 74
-#define NS_HTML5TOKENIZER_LEAD_OFFSET (0xD800 - (0x10000 >> 10))
-
-
 #endif
 
--- a/parser/html/nsHtml5TokenizerCppSupplement.h
+++ b/parser/html/nsHtml5TokenizerCppSupplement.h
@@ -57,17 +57,17 @@ nsHtml5Tokenizer::EnsureBufferSpace(int3
     strBuf = newBuf;
   }
   return true;
 }
 
 void
 nsHtml5Tokenizer::StartPlainText()
 {
-  stateSave = NS_HTML5TOKENIZER_PLAINTEXT;
+  stateSave = nsHtml5Tokenizer::PLAINTEXT;
 }
 
 void
 nsHtml5Tokenizer::EnableViewSource(nsHtml5Highlighter* aHighlighter)
 {
   mViewSource = aHighlighter;
 }
 
--- a/parser/html/nsHtml5TreeBuilder.cpp
+++ b/parser/html/nsHtml5TreeBuilder.cpp
@@ -51,20 +51,20 @@
 #include "nsAHtml5TreeBuilderState.h"
 #include "nsHtml5Highlighter.h"
 #include "nsHtml5PlainTextUtils.h"
 #include "nsHtml5ViewSourceUtils.h"
 #include "mozilla/Likely.h"
 #include "nsIContentHandle.h"
 #include "nsHtml5OplessBuilder.h"
 
+#include "nsHtml5AttributeName.h"
+#include "nsHtml5ElementName.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5MetaScanner.h"
-#include "nsHtml5AttributeName.h"
-#include "nsHtml5ElementName.h"
 #include "nsHtml5StackNode.h"
 #include "nsHtml5UTF16Buffer.h"
 #include "nsHtml5StateSnapshot.h"
 #include "nsHtml5Portability.h"
 
 #include "nsHtml5TreeBuilder.h"
 
 char16_t nsHtml5TreeBuilder::REPLACEMENT_CHARACTER[] = { 0xfffd };
@@ -73,17 +73,17 @@ staticJArray<const char*,int32_t> nsHtml
 void 
 nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
 {
   tokenizer = self;
   stack = jArray<nsHtml5StackNode*,int32_t>::newJArray(64);
   templateModeStack = jArray<int32_t,int32_t>::newJArray(64);
   listOfActiveFormattingElements = jArray<nsHtml5StackNode*,int32_t>::newJArray(64);
   needToDropLF = false;
-  originalMode = NS_HTML5TREE_BUILDER_INITIAL;
+  originalMode = INITIAL;
   templateModePtr = -1;
   currentPtr = -1;
   listPtr = -1;
   formPointer = nullptr;
   headPointer = nullptr;
   deepTreeSurrogateParent = nullptr;
   start(fragment);
   charBufferLen = 0;
@@ -100,106 +100,113 @@ nsHtml5TreeBuilder::startTokenization(ns
       nsHtml5ElementName* elementName = nsHtml5ElementName::ELT_SVG;
       if (nsHtml5Atoms::title == contextName || nsHtml5Atoms::desc == contextName || nsHtml5Atoms::foreignObject == contextName) {
         elementName = nsHtml5ElementName::ELT_FOREIGNOBJECT;
       }
       nsHtml5StackNode* node =
         new nsHtml5StackNode(elementName, elementName->getCamelCaseName(), elt);
       currentPtr++;
       stack[currentPtr] = node;
-      tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_DATA, contextName);
-      mode = NS_HTML5TREE_BUILDER_FRAMESET_OK;
+      tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::DATA,
+                                              contextName);
+      mode = FRAMESET_OK;
     } else if (contextNamespace == kNameSpaceID_MathML) {
       nsHtml5ElementName* elementName = nsHtml5ElementName::ELT_MATH;
       if (nsHtml5Atoms::mi == contextName || nsHtml5Atoms::mo == contextName || nsHtml5Atoms::mn == contextName || nsHtml5Atoms::ms == contextName || nsHtml5Atoms::mtext == contextName) {
         elementName = nsHtml5ElementName::ELT_MTEXT;
       } else if (nsHtml5Atoms::annotation_xml == contextName) {
         elementName = nsHtml5ElementName::ELT_ANNOTATION_XML;
       }
       nsHtml5StackNode* node =
         new nsHtml5StackNode(elementName, elt, elementName->getName(), false);
       currentPtr++;
       stack[currentPtr] = node;
-      tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_DATA, contextName);
-      mode = NS_HTML5TREE_BUILDER_FRAMESET_OK;
+      tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::DATA,
+                                              contextName);
+      mode = FRAMESET_OK;
     } else {
       nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HTML, elt);
       currentPtr++;
       stack[currentPtr] = node;
       if (nsHtml5Atoms::template_ == contextName) {
-        pushTemplateMode(NS_HTML5TREE_BUILDER_IN_TEMPLATE);
+        pushTemplateMode(IN_TEMPLATE);
       }
       resetTheInsertionMode();
       formPointer = getFormPointerForContext(contextNode);
       if (nsHtml5Atoms::title == contextName || nsHtml5Atoms::textarea == contextName) {
-        tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RCDATA, contextName);
+        tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::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);
+        tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::RAWTEXT,
+                                                contextName);
       } else if (nsHtml5Atoms::plaintext == contextName) {
-        tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_PLAINTEXT, contextName);
+        tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::PLAINTEXT,
+                                                contextName);
       } else if (nsHtml5Atoms::script == contextName) {
-        tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, contextName);
+        tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::SCRIPT_DATA,
+                                                contextName);
       } else {
-        tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_DATA, contextName);
+        tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::DATA,
+                                                contextName);
       }
     }
     contextName = nullptr;
     contextNode = nullptr;
   } else {
-    mode = NS_HTML5TREE_BUILDER_INITIAL;
+    mode = INITIAL;
     if (tokenizer->isViewingXmlSource()) {
       nsIContentHandle* elt = createElement(kNameSpaceID_SVG, nsHtml5Atoms::svg, tokenizer->emptyAttributes(), nullptr);
       nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_SVG, nsHtml5Atoms::svg, elt);
       currentPtr++;
       stack[currentPtr] = node;
     }
   }
 }
 
 void
 nsHtml5TreeBuilder::doctype(nsIAtom* name,
                             nsHtml5String publicIdentifier,
                             nsHtml5String systemIdentifier,
                             bool forceQuirks)
 {
   needToDropLF = false;
-  if (!isInForeign() && mode == NS_HTML5TREE_BUILDER_INITIAL) {
+  if (!isInForeign() && mode == INITIAL) {
     nsHtml5String emptyString = nsHtml5Portability::newEmptyString();
     appendDoctypeToDocument(!name ? nsHtml5Atoms::emptystring : name, !publicIdentifier ? emptyString : publicIdentifier, !systemIdentifier ? emptyString : systemIdentifier);
     emptyString.Release();
     if (isQuirky(name, publicIdentifier, systemIdentifier, forceQuirks)) {
       errQuirkyDoctype();
       documentModeInternal(QUIRKS_MODE, publicIdentifier, systemIdentifier, false);
     } else if (isAlmostStandards(publicIdentifier, systemIdentifier)) {
       errAlmostStandardsDoctype();
       documentModeInternal(ALMOST_STANDARDS_MODE, publicIdentifier, systemIdentifier, false);
     } else {
       documentModeInternal(STANDARDS_MODE, publicIdentifier, systemIdentifier, false);
     }
-    mode = NS_HTML5TREE_BUILDER_BEFORE_HTML;
+    mode = BEFORE_HTML;
     return;
   }
   errStrayDoctype();
   return;
 }
 
 void 
 nsHtml5TreeBuilder::comment(char16_t* buf, int32_t start, int32_t length)
 {
   needToDropLF = false;
   if (!isInForeign()) {
     switch(mode) {
-      case NS_HTML5TREE_BUILDER_INITIAL:
-      case NS_HTML5TREE_BUILDER_BEFORE_HTML:
-      case NS_HTML5TREE_BUILDER_AFTER_AFTER_BODY:
-      case NS_HTML5TREE_BUILDER_AFTER_AFTER_FRAMESET: {
+      case INITIAL:
+      case BEFORE_HTML:
+      case AFTER_AFTER_BODY:
+      case AFTER_AFTER_FRAMESET: {
         appendCommentToDocument(buf, start, length);
         return;
       }
-      case NS_HTML5TREE_BUILDER_AFTER_BODY: {
+      case AFTER_BODY: {
         flushCharacters();
         appendComment(stack[0]->node, buf, start, length);
         return;
       }
       default: {
         break;
       }
     }
@@ -221,232 +228,233 @@ nsHtml5TreeBuilder::characters(const cha
       start++;
       length--;
       if (!length) {
         return;
       }
     }
   }
   switch(mode) {
-    case NS_HTML5TREE_BUILDER_IN_BODY:
-    case NS_HTML5TREE_BUILDER_IN_CELL:
-    case NS_HTML5TREE_BUILDER_IN_CAPTION: {
+    case IN_BODY:
+    case IN_CELL:
+    case IN_CAPTION: {
       if (!isInForeignButNotHtmlOrMathTextIntegrationPoint()) {
         reconstructTheActiveFormattingElements();
       }
     }
-    case NS_HTML5TREE_BUILDER_TEXT: {
+    case TEXT: {
       accumulateCharacters(buf, start, length);
       return;
     }
-    case NS_HTML5TREE_BUILDER_IN_TABLE:
-    case NS_HTML5TREE_BUILDER_IN_TABLE_BODY:
-    case NS_HTML5TREE_BUILDER_IN_ROW: {
+    case IN_TABLE:
+    case IN_TABLE_BODY:
+    case IN_ROW: {
       accumulateCharactersForced(buf, start, length);
       return;
     }
     default: {
       int32_t end = start + length;
       for (int32_t i = start; i < end; i++) {
         switch(buf[i]) {
           case ' ':
           case '\t':
           case '\n':
           case '\r':
           case '\f': {
             switch(mode) {
-              case NS_HTML5TREE_BUILDER_INITIAL:
-              case NS_HTML5TREE_BUILDER_BEFORE_HTML:
-              case NS_HTML5TREE_BUILDER_BEFORE_HEAD: {
+              case INITIAL:
+              case BEFORE_HTML:
+              case BEFORE_HEAD: {
                 start = i + 1;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_IN_HEAD:
-              case NS_HTML5TREE_BUILDER_IN_HEAD_NOSCRIPT:
-              case NS_HTML5TREE_BUILDER_AFTER_HEAD:
-              case NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP:
-              case NS_HTML5TREE_BUILDER_IN_FRAMESET:
-              case NS_HTML5TREE_BUILDER_AFTER_FRAMESET: {
+              case IN_HEAD:
+              case IN_HEAD_NOSCRIPT:
+              case AFTER_HEAD:
+              case IN_COLUMN_GROUP:
+              case IN_FRAMESET:
+              case AFTER_FRAMESET: {
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_FRAMESET_OK:
-              case NS_HTML5TREE_BUILDER_IN_TEMPLATE:
-              case NS_HTML5TREE_BUILDER_IN_BODY:
-              case NS_HTML5TREE_BUILDER_IN_CELL:
-              case NS_HTML5TREE_BUILDER_IN_CAPTION: {
+              case FRAMESET_OK:
+              case IN_TEMPLATE:
+              case IN_BODY:
+              case IN_CELL:
+              case IN_CAPTION: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                   start = i;
                 }
                 if (!isInForeignButNotHtmlOrMathTextIntegrationPoint()) {
                   flushCharacters();
                   reconstructTheActiveFormattingElements();
                 }
                 NS_HTML5_BREAK(charactersloop);
               }
-              case NS_HTML5TREE_BUILDER_IN_SELECT:
-              case NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE: {
+              case IN_SELECT:
+              case IN_SELECT_IN_TABLE: {
                 NS_HTML5_BREAK(charactersloop);
               }
-              case NS_HTML5TREE_BUILDER_IN_TABLE:
-              case NS_HTML5TREE_BUILDER_IN_TABLE_BODY:
-              case NS_HTML5TREE_BUILDER_IN_ROW: {
+              case IN_TABLE:
+              case IN_TABLE_BODY:
+              case IN_ROW: {
                 accumulateCharactersForced(buf, i, 1);
                 start = i + 1;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_AFTER_BODY:
-              case NS_HTML5TREE_BUILDER_AFTER_AFTER_BODY:
-              case NS_HTML5TREE_BUILDER_AFTER_AFTER_FRAMESET: {
+              case AFTER_BODY:
+              case AFTER_AFTER_BODY:
+              case AFTER_AFTER_FRAMESET: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                   start = i;
                 }
                 flushCharacters();
                 reconstructTheActiveFormattingElements();
                 continue;
               }
             }
           }
           default: {
             switch(mode) {
-              case NS_HTML5TREE_BUILDER_INITIAL: {
+              case INITIAL: {
                 documentModeInternal(QUIRKS_MODE, nullptr, nullptr, false);
-                mode = NS_HTML5TREE_BUILDER_BEFORE_HTML;
+                mode = BEFORE_HTML;
                 i--;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_BEFORE_HTML: {
+              case BEFORE_HTML: {
                 appendHtmlElementToDocumentAndPush();
-                mode = NS_HTML5TREE_BUILDER_BEFORE_HEAD;
+                mode = BEFORE_HEAD;
                 i--;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_BEFORE_HEAD: {
+              case BEFORE_HEAD: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                   start = i;
                 }
                 flushCharacters();
                 appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
-                mode = NS_HTML5TREE_BUILDER_IN_HEAD;
+                mode = IN_HEAD;
                 i--;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_IN_HEAD: {
+              case IN_HEAD: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                   start = i;
                 }
                 flushCharacters();
                 pop();
-                mode = NS_HTML5TREE_BUILDER_AFTER_HEAD;
+                mode = AFTER_HEAD;
                 i--;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_IN_HEAD_NOSCRIPT: {
+              case IN_HEAD_NOSCRIPT: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                   start = i;
                 }
                 errNonSpaceInNoscriptInHead();
                 flushCharacters();
                 pop();
-                mode = NS_HTML5TREE_BUILDER_IN_HEAD;
+                mode = IN_HEAD;
                 i--;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_AFTER_HEAD: {
+              case AFTER_HEAD: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                   start = i;
                 }
                 flushCharacters();
                 appendToCurrentNodeAndPushBodyElement();
-                mode = NS_HTML5TREE_BUILDER_FRAMESET_OK;
+                mode = FRAMESET_OK;
                 i--;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_FRAMESET_OK: {
+              case FRAMESET_OK: {
                 framesetOk = false;
-                mode = NS_HTML5TREE_BUILDER_IN_BODY;
+                mode = IN_BODY;
                 i--;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_IN_TEMPLATE:
-              case NS_HTML5TREE_BUILDER_IN_BODY:
-              case NS_HTML5TREE_BUILDER_IN_CELL:
-              case NS_HTML5TREE_BUILDER_IN_CAPTION: {
+              case IN_TEMPLATE:
+              case IN_BODY:
+              case IN_CELL:
+              case IN_CAPTION: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                   start = i;
                 }
                 if (!isInForeignButNotHtmlOrMathTextIntegrationPoint()) {
                   flushCharacters();
                   reconstructTheActiveFormattingElements();
                 }
                 NS_HTML5_BREAK(charactersloop);
               }
-              case NS_HTML5TREE_BUILDER_IN_TABLE:
-              case NS_HTML5TREE_BUILDER_IN_TABLE_BODY:
-              case NS_HTML5TREE_BUILDER_IN_ROW: {
+              case IN_TABLE:
+              case IN_TABLE_BODY:
+              case IN_ROW: {
                 accumulateCharactersForced(buf, i, 1);
                 start = i + 1;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP: {
+              case IN_COLUMN_GROUP: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                   start = i;
                 }
-                if (!currentPtr || stack[currentPtr]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE) {
+                if (!currentPtr || stack[currentPtr]->getGroup() ==
+                                     nsHtml5TreeBuilder::TEMPLATE) {
                   errNonSpaceInColgroupInFragment();
                   start = i + 1;
                   continue;
                 }
                 flushCharacters();
                 pop();
-                mode = NS_HTML5TREE_BUILDER_IN_TABLE;
+                mode = IN_TABLE;
                 i--;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_IN_SELECT:
-              case NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE: {
+              case IN_SELECT:
+              case IN_SELECT_IN_TABLE: {
                 NS_HTML5_BREAK(charactersloop);
               }
-              case NS_HTML5TREE_BUILDER_AFTER_BODY: {
+              case AFTER_BODY: {
                 errNonSpaceAfterBody();
 
-                mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
+                mode = framesetOk ? FRAMESET_OK : IN_BODY;
                 i--;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_IN_FRAMESET: {
+              case IN_FRAMESET: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                 }
                 errNonSpaceInFrameset();
                 start = i + 1;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_AFTER_FRAMESET: {
+              case AFTER_FRAMESET: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                 }
                 errNonSpaceAfterFrameset();
                 start = i + 1;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_AFTER_AFTER_BODY: {
+              case AFTER_AFTER_BODY: {
                 errNonSpaceInTrailer();
-                mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
+                mode = framesetOk ? FRAMESET_OK : IN_BODY;
                 i--;
                 continue;
               }
-              case NS_HTML5TREE_BUILDER_AFTER_AFTER_FRAMESET: {
+              case AFTER_AFTER_FRAMESET: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                 }
                 errNonSpaceInTrailer();
                 start = i + 1;
                 continue;
               }
             }
@@ -459,17 +467,17 @@ nsHtml5TreeBuilder::characters(const cha
       }
     }
   }
 }
 
 void 
 nsHtml5TreeBuilder::zeroOriginatingReplacementCharacter()
 {
-  if (mode == NS_HTML5TREE_BUILDER_TEXT) {
+  if (mode == TEXT) {
     accumulateCharacters(REPLACEMENT_CHARACTER, 0, 1);
     return;
   }
   if (currentPtr >= 0) {
     if (isSpecialParentInForeign(stack[currentPtr])) {
       return;
     }
     accumulateCharacters(REPLACEMENT_CHARACTER, 0, 1);
@@ -477,96 +485,96 @@ nsHtml5TreeBuilder::zeroOriginatingRepla
 }
 
 void 
 nsHtml5TreeBuilder::eof()
 {
   flushCharacters();
   for (; ; ) {
     switch(mode) {
-      case NS_HTML5TREE_BUILDER_INITIAL: {
+      case INITIAL: {
         documentModeInternal(QUIRKS_MODE, nullptr, nullptr, false);
-        mode = NS_HTML5TREE_BUILDER_BEFORE_HTML;
+        mode = BEFORE_HTML;
         continue;
       }
-      case NS_HTML5TREE_BUILDER_BEFORE_HTML: {
+      case BEFORE_HTML: {
         appendHtmlElementToDocumentAndPush();
-        mode = NS_HTML5TREE_BUILDER_BEFORE_HEAD;
+        mode = BEFORE_HEAD;
         continue;
       }
-      case NS_HTML5TREE_BUILDER_BEFORE_HEAD: {
+      case BEFORE_HEAD: {
         appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
-        mode = NS_HTML5TREE_BUILDER_IN_HEAD;
+        mode = IN_HEAD;
         continue;
       }
-      case NS_HTML5TREE_BUILDER_IN_HEAD: {
+      case IN_HEAD: {
         while (currentPtr > 0) {
           popOnEof();
         }
-        mode = NS_HTML5TREE_BUILDER_AFTER_HEAD;
+        mode = AFTER_HEAD;
         continue;
       }
-      case NS_HTML5TREE_BUILDER_IN_HEAD_NOSCRIPT: {
+      case IN_HEAD_NOSCRIPT: {
         while (currentPtr > 1) {
           popOnEof();
         }
-        mode = NS_HTML5TREE_BUILDER_IN_HEAD;
+        mode = IN_HEAD;
         continue;
       }
-      case NS_HTML5TREE_BUILDER_AFTER_HEAD: {
+      case AFTER_HEAD: {
         appendToCurrentNodeAndPushBodyElement();
-        mode = NS_HTML5TREE_BUILDER_IN_BODY;
+        mode = IN_BODY;
         continue;
       }
-      case NS_HTML5TREE_BUILDER_IN_TABLE_BODY:
-      case NS_HTML5TREE_BUILDER_IN_ROW:
-      case NS_HTML5TREE_BUILDER_IN_TABLE:
-      case NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE:
-      case NS_HTML5TREE_BUILDER_IN_SELECT:
-      case NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP:
-      case NS_HTML5TREE_BUILDER_FRAMESET_OK:
-      case NS_HTML5TREE_BUILDER_IN_CAPTION:
-      case NS_HTML5TREE_BUILDER_IN_CELL:
-      case NS_HTML5TREE_BUILDER_IN_BODY: {
+      case IN_TABLE_BODY:
+      case IN_ROW:
+      case IN_TABLE:
+      case IN_SELECT_IN_TABLE:
+      case IN_SELECT:
+      case IN_COLUMN_GROUP:
+      case FRAMESET_OK:
+      case IN_CAPTION:
+      case IN_CELL:
+      case IN_BODY: {
         if (isTemplateModeStackEmpty()) {
           NS_HTML5_BREAK(eofloop);
         }
       }
-      case NS_HTML5TREE_BUILDER_IN_TEMPLATE: {
+      case IN_TEMPLATE: {
         int32_t eltPos = findLast(nsHtml5Atoms::template_);
-        if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+        if (eltPos == nsHtml5TreeBuilder::NOT_FOUND_ON_STACK) {
           MOZ_ASSERT(fragment);
           NS_HTML5_BREAK(eofloop);
         }
         if (MOZ_UNLIKELY(mViewSource)) {
           errUnclosedElements(eltPos, nsHtml5Atoms::template_);
         }
         while (currentPtr >= eltPos) {
           pop();
         }
         clearTheListOfActiveFormattingElementsUpToTheLastMarker();
         popTemplateMode();
         resetTheInsertionMode();
         continue;
       }
-      case NS_HTML5TREE_BUILDER_TEXT: {
-        if (originalMode == NS_HTML5TREE_BUILDER_AFTER_HEAD) {
+      case TEXT: {
+        if (originalMode == AFTER_HEAD) {
           popOnEof();
         }
         popOnEof();
         mode = originalMode;
         continue;
       }
-      case NS_HTML5TREE_BUILDER_IN_FRAMESET: {
+      case IN_FRAMESET: {
         NS_HTML5_BREAK(eofloop);
       }
-      case NS_HTML5TREE_BUILDER_AFTER_BODY:
-      case NS_HTML5TREE_BUILDER_AFTER_FRAMESET:
-      case NS_HTML5TREE_BUILDER_AFTER_AFTER_BODY:
-      case NS_HTML5TREE_BUILDER_AFTER_AFTER_FRAMESET:
+      case AFTER_BODY:
+      case AFTER_FRAMESET:
+      case AFTER_AFTER_BODY:
+      case AFTER_AFTER_FRAMESET:
       default: {
         NS_HTML5_BREAK(eofloop);
       }
     }
   }
   eofloop_end: ;
   while (currentPtr > 0) {
     popOnEof();
@@ -610,38 +618,45 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
   int32_t eltPos;
   needToDropLF = false;
   starttagloop: for (; ; ) {
     int32_t group = elementName->getGroup();
     nsIAtom* name = elementName->getName();
     if (isInForeign()) {
       nsHtml5StackNode* currentNode = stack[currentPtr];
       int32_t currNs = currentNode->ns;
-      if (!(currentNode->isHtmlIntegrationPoint() || (currNs == kNameSpaceID_MathML && ((currentNode->getGroup() == NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT && group != NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK) || (currentNode->getGroup() == NS_HTML5TREE_BUILDER_ANNOTATION_XML && group == NS_HTML5TREE_BUILDER_SVG))))) {
+      if (!(currentNode->isHtmlIntegrationPoint() ||
+            (currNs == kNameSpaceID_MathML &&
+             ((currentNode->getGroup() == MI_MO_MN_MS_MTEXT &&
+               group != MGLYPH_OR_MALIGNMARK) ||
+              (currentNode->getGroup() == ANNOTATION_XML && group == SVG))))) {
         switch(group) {
-          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_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU:
-          case NS_HTML5TREE_BUILDER_BODY:
-          case NS_HTML5TREE_BUILDER_BR:
-          case NS_HTML5TREE_BUILDER_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR:
-          case NS_HTML5TREE_BUILDER_DD_OR_DT:
-          case NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL:
-          case NS_HTML5TREE_BUILDER_EMBED:
-          case NS_HTML5TREE_BUILDER_IMG:
-          case NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6:
-          case NS_HTML5TREE_BUILDER_HEAD:
-          case NS_HTML5TREE_BUILDER_HR:
-          case NS_HTML5TREE_BUILDER_LI:
-          case NS_HTML5TREE_BUILDER_META:
-          case NS_HTML5TREE_BUILDER_NOBR:
-          case NS_HTML5TREE_BUILDER_P:
-          case NS_HTML5TREE_BUILDER_PRE_OR_LISTING:
-          case NS_HTML5TREE_BUILDER_TABLE:
-          case NS_HTML5TREE_BUILDER_FONT: {
-            if (!(group == NS_HTML5TREE_BUILDER_FONT && !(attributes->contains(nsHtml5AttributeName::ATTR_COLOR) || attributes->contains(nsHtml5AttributeName::ATTR_FACE) || attributes->contains(nsHtml5AttributeName::ATTR_SIZE)))) {
+          case B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U:
+          case DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU:
+          case BODY:
+          case BR:
+          case RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR:
+          case DD_OR_DT:
+          case UL_OR_OL_OR_DL:
+          case EMBED:
+          case IMG:
+          case H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6:
+          case HEAD:
+          case HR:
+          case LI:
+          case META:
+          case NOBR:
+          case P:
+          case PRE_OR_LISTING:
+          case TABLE:
+          case FONT: {
+            if (!(group == FONT &&
+                  !(attributes->contains(nsHtml5AttributeName::ATTR_COLOR) ||
+                    attributes->contains(nsHtml5AttributeName::ATTR_FACE) ||
+                    attributes->contains(nsHtml5AttributeName::ATTR_SIZE)))) {
               errHtmlStartTagInForeignContext(name);
               if (!fragment) {
                 while (!isSpecialParentInForeign(stack[currentPtr])) {
                   pop();
                 }
                 NS_HTML5_CONTINUE(starttagloop);
               }
             }
@@ -668,238 +683,240 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
           }
         }
       }
     }
     switch(mode) {
-      case NS_HTML5TREE_BUILDER_IN_TEMPLATE: {
+      case IN_TEMPLATE: {
         switch(group) {
-          case NS_HTML5TREE_BUILDER_COL: {
+          case COL: {
             popTemplateMode();
-            pushTemplateMode(NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP);
-            mode = NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP;
+            pushTemplateMode(IN_COLUMN_GROUP);
+            mode = IN_COLUMN_GROUP;
             continue;
           }
-          case NS_HTML5TREE_BUILDER_CAPTION:
-          case NS_HTML5TREE_BUILDER_COLGROUP:
-          case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT: {
+          case CAPTION:
+          case COLGROUP:
+          case TBODY_OR_THEAD_OR_TFOOT: {
             popTemplateMode();
-            pushTemplateMode(NS_HTML5TREE_BUILDER_IN_TABLE);
-            mode = NS_HTML5TREE_BUILDER_IN_TABLE;
+            pushTemplateMode(IN_TABLE);
+            mode = IN_TABLE;
             continue;
           }
-          case NS_HTML5TREE_BUILDER_TR: {
+          case TR: {
             popTemplateMode();
-            pushTemplateMode(NS_HTML5TREE_BUILDER_IN_TABLE_BODY);
-            mode = NS_HTML5TREE_BUILDER_IN_TABLE_BODY;
+            pushTemplateMode(IN_TABLE_BODY);
+            mode = IN_TABLE_BODY;
             continue;
           }
-          case NS_HTML5TREE_BUILDER_TD_OR_TH: {
+          case TD_OR_TH: {
             popTemplateMode();
-            pushTemplateMode(NS_HTML5TREE_BUILDER_IN_ROW);
-            mode = NS_HTML5TREE_BUILDER_IN_ROW;
+            pushTemplateMode(IN_ROW);
+            mode = IN_ROW;
             continue;
           }
-          case NS_HTML5TREE_BUILDER_META: {
+          case META: {
             checkMetaCharset(attributes);
             appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = false;
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_TITLE: {
+          case TITLE: {
             startTagTitleInHead(elementName, attributes);
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_BASE:
-          case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND: {
+          case BASE:
+          case LINK_OR_BASEFONT_OR_BGSOUND: {
             appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = false;
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_SCRIPT: {
+          case SCRIPT: {
             startTagScriptInHead(elementName, attributes);
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_NOFRAMES:
-          case NS_HTML5TREE_BUILDER_STYLE: {
+          case NOFRAMES:
+          case STYLE: {
             startTagGenericRawText(elementName, attributes);
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_TEMPLATE: {
+          case TEMPLATE: {
             startTagTemplateInHead(elementName, attributes);
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
           default: {
             popTemplateMode();
-            pushTemplateMode(NS_HTML5TREE_BUILDER_IN_BODY);
-            mode = NS_HTML5TREE_BUILDER_IN_BODY;
+            pushTemplateMode(IN_BODY);
+            mode = IN_BODY;
             continue;
           }
         }
       }
-      case NS_HTML5TREE_BUILDER_IN_ROW: {
+      case IN_ROW: {
         switch(group) {
-          case NS_HTML5TREE_BUILDER_TD_OR_TH: {
-            clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TR));
+          case TD_OR_TH: {
+            clearStackBackTo(findLastOrRoot(nsHtml5TreeBuilder::TR));
             appendToCurrentNodeAndPushElement(elementName, attributes);
-            mode = NS_HTML5TREE_BUILDER_IN_CELL;
+            mode = IN_CELL;
             insertMarker();
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_CAPTION:
-          case NS_HTML5TREE_BUILDER_COL:
-          case NS_HTML5TREE_BUILDER_COLGROUP:
-          case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT:
-          case NS_HTML5TREE_BUILDER_TR: {
-            eltPos = findLastOrRoot(NS_HTML5TREE_BUILDER_TR);
+          case CAPTION:
+          case COL:
+          case COLGROUP:
+          case TBODY_OR_THEAD_OR_TFOOT:
+          case TR: {
+            eltPos = findLastOrRoot(nsHtml5TreeBuilder::TR);
             if (!eltPos) {
               MOZ_ASSERT(fragment || isTemplateContents());
               errNoTableRowToClose();
               NS_HTML5_BREAK(starttagloop);
             }
             clearStackBackTo(eltPos);
             pop();
-            mode = NS_HTML5TREE_BUILDER_IN_TABLE_BODY;
+            mode = IN_TABLE_BODY;
             continue;
           }
           default:
             ; // fall through
         }
       }
-      case NS_HTML5TREE_BUILDER_IN_TABLE_BODY: {
+      case IN_TABLE_BODY: {
         switch(group) {
-          case NS_HTML5TREE_BUILDER_TR: {
+          case TR: {
             clearStackBackTo(findLastInTableScopeOrRootTemplateTbodyTheadTfoot());
             appendToCurrentNodeAndPushElement(elementName, attributes);
-            mode = NS_HTML5TREE_BUILDER_IN_ROW;
+            mode = IN_ROW;
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_TD_OR_TH: {
+          case TD_OR_TH: {
             errStartTagInTableBody(name);
             clearStackBackTo(findLastInTableScopeOrRootTemplateTbodyTheadTfoot());
             appendToCurrentNodeAndPushElement(nsHtml5ElementName::ELT_TR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
-            mode = NS_HTML5TREE_BUILDER_IN_ROW;
+            mode = 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: {
+          case CAPTION:
+          case COL:
+          case COLGROUP:
+          case TBODY_OR_THEAD_OR_TFOOT: {
             eltPos = findLastInTableScopeOrRootTemplateTbodyTheadTfoot();
-            if (!eltPos || stack[eltPos]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE) {
+            if (!eltPos || stack[eltPos]->getGroup() == TEMPLATE) {
               MOZ_ASSERT(fragment || isTemplateContents());
               errStrayStartTag(name);
               NS_HTML5_BREAK(starttagloop);
             } else {
               clearStackBackTo(eltPos);
               pop();
-              mode = NS_HTML5TREE_BUILDER_IN_TABLE;
+              mode = IN_TABLE;
               continue;
             }
           }
           default:
             ; // fall through
         }
       }
-      case NS_HTML5TREE_BUILDER_IN_TABLE: {
+      case IN_TABLE: {
         for (; ; ) {
           switch(group) {
-            case NS_HTML5TREE_BUILDER_CAPTION: {
-              clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE));
+            case CAPTION: {
+              clearStackBackTo(findLastOrRoot(nsHtml5TreeBuilder::TABLE));
               insertMarker();
               appendToCurrentNodeAndPushElement(elementName, attributes);
-              mode = NS_HTML5TREE_BUILDER_IN_CAPTION;
+              mode = IN_CAPTION;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_COLGROUP: {
-              clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE));
+            case COLGROUP: {
+              clearStackBackTo(findLastOrRoot(nsHtml5TreeBuilder::TABLE));
               appendToCurrentNodeAndPushElement(elementName, attributes);
-              mode = NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP;
+              mode = IN_COLUMN_GROUP;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_COL: {
-              clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE));
+            case COL: {
+              clearStackBackTo(findLastOrRoot(nsHtml5TreeBuilder::TABLE));
               appendToCurrentNodeAndPushElement(nsHtml5ElementName::ELT_COLGROUP, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
-              mode = NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP;
+              mode = IN_COLUMN_GROUP;
               NS_HTML5_CONTINUE(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT: {
-              clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE));
+            case TBODY_OR_THEAD_OR_TFOOT: {
+              clearStackBackTo(findLastOrRoot(nsHtml5TreeBuilder::TABLE));
               appendToCurrentNodeAndPushElement(elementName, attributes);
-              mode = NS_HTML5TREE_BUILDER_IN_TABLE_BODY;
+              mode = IN_TABLE_BODY;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_TR:
-            case NS_HTML5TREE_BUILDER_TD_OR_TH: {
-              clearStackBackTo(findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE));
+            case TR:
+            case TD_OR_TH: {
+              clearStackBackTo(findLastOrRoot(nsHtml5TreeBuilder::TABLE));
               appendToCurrentNodeAndPushElement(nsHtml5ElementName::ELT_TBODY, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
-              mode = NS_HTML5TREE_BUILDER_IN_TABLE_BODY;
+              mode = IN_TABLE_BODY;
               NS_HTML5_CONTINUE(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_TEMPLATE: {
+            case TEMPLATE: {
               NS_HTML5_BREAK(intableloop);
             }
-            case NS_HTML5TREE_BUILDER_TABLE: {
+            case TABLE: {
               errTableSeenWhileTableOpen();
               eltPos = findLastInTableScope(name);
-              if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+              if (eltPos == nsHtml5TreeBuilder::NOT_FOUND_ON_STACK) {
                 MOZ_ASSERT(fragment || isTemplateContents());
                 NS_HTML5_BREAK(starttagloop);
               }
               generateImpliedEndTags();
               if (!!MOZ_UNLIKELY(mViewSource) && !isCurrent(nsHtml5Atoms::table)) {
                 errNoCheckUnclosedElementsOnStack();
               }
               while (currentPtr >= eltPos) {
                 pop();
               }
               resetTheInsertionMode();
               NS_HTML5_CONTINUE(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_SCRIPT: {
+            case SCRIPT: {
               appendToCurrentNodeAndPushElement(elementName, attributes);
               originalMode = mode;
-              mode = NS_HTML5TREE_BUILDER_TEXT;
-              tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, elementName);
+              mode = TEXT;
+              tokenizer->setStateAndEndTagExpectation(
+                nsHtml5Tokenizer::SCRIPT_DATA, elementName);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_STYLE: {
+            case STYLE: {
               appendToCurrentNodeAndPushElement(elementName, attributes);
               originalMode = mode;
-              mode = NS_HTML5TREE_BUILDER_TEXT;
-              tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
+              mode = TEXT;
+              tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::RAWTEXT,
+                                                      elementName);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_INPUT: {
+            case INPUT: {
               errStartTagInTable(name);
               if (!nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("hidden", attributes->getValue(nsHtml5AttributeName::ATTR_TYPE))) {
                 NS_HTML5_BREAK(intableloop);
               }
               appendVoidElementToCurrent(name, attributes, formPointer);
               selfClosing = false;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_FORM: {
+            case FORM: {
               if (!!formPointer || isTemplateContents()) {
                 errFormWhenFormOpen();
                 NS_HTML5_BREAK(starttagloop);
               } else {
                 errStartTagInTable(name);
                 appendVoidFormToCurrent(attributes);
                 attributes = nullptr;
                 NS_HTML5_BREAK(starttagloop);
@@ -908,197 +925,204 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
             default: {
               errStartTagInTable(name);
               NS_HTML5_BREAK(intableloop);
             }
           }
         }
         intableloop_end: ;
       }
-      case NS_HTML5TREE_BUILDER_IN_CAPTION: {
+      case IN_CAPTION: {
         switch(group) {
-          case NS_HTML5TREE_BUILDER_CAPTION:
-          case NS_HTML5TREE_BUILDER_COL:
-          case NS_HTML5TREE_BUILDER_COLGROUP:
-          case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT:
-          case NS_HTML5TREE_BUILDER_TR:
-          case NS_HTML5TREE_BUILDER_TD_OR_TH: {
+          case CAPTION:
+          case COL:
+          case COLGROUP:
+          case TBODY_OR_THEAD_OR_TFOOT:
+          case TR:
+          case TD_OR_TH: {
             errStrayStartTag(name);
             eltPos = findLastInTableScope(nsHtml5Atoms::caption);
-            if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+            if (eltPos == nsHtml5TreeBuilder::NOT_FOUND_ON_STACK) {
               NS_HTML5_BREAK(starttagloop);
             }
             generateImpliedEndTags();
             if (!!MOZ_UNLIKELY(mViewSource) && currentPtr != eltPos) {
               errNoCheckUnclosedElementsOnStack();
             }
             while (currentPtr >= eltPos) {
               pop();
             }
             clearTheListOfActiveFormattingElementsUpToTheLastMarker();
-            mode = NS_HTML5TREE_BUILDER_IN_TABLE;
+            mode = IN_TABLE;
             continue;
           }
           default:
             ; // fall through
         }
       }
-      case NS_HTML5TREE_BUILDER_IN_CELL: {
+      case IN_CELL: {
         switch(group) {
-          case NS_HTML5TREE_BUILDER_CAPTION:
-          case NS_HTML5TREE_BUILDER_COL:
-          case NS_HTML5TREE_BUILDER_COLGROUP:
-          case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT:
-          case NS_HTML5TREE_BUILDER_TR:
-          case NS_HTML5TREE_BUILDER_TD_OR_TH: {
+          case CAPTION:
+          case COL:
+          case COLGROUP:
+          case TBODY_OR_THEAD_OR_TFOOT:
+          case TR:
+          case TD_OR_TH: {
             eltPos = findLastInTableScopeTdTh();
-            if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+            if (eltPos == nsHtml5TreeBuilder::NOT_FOUND_ON_STACK) {
               errNoCellToClose();
               NS_HTML5_BREAK(starttagloop);
             } else {
               closeTheCell(eltPos);
               continue;
             }
           }
           default:
             ; // fall through
         }
       }
-      case NS_HTML5TREE_BUILDER_FRAMESET_OK: {
+      case FRAMESET_OK: {
         switch(group) {
-          case NS_HTML5TREE_BUILDER_FRAMESET: {
-            if (mode == NS_HTML5TREE_BUILDER_FRAMESET_OK) {
-              if (!currentPtr || stack[1]->getGroup() != NS_HTML5TREE_BUILDER_BODY) {
+          case FRAMESET: {
+            if (mode == FRAMESET_OK) {
+              if (!currentPtr || stack[1]->getGroup() != BODY) {
                 MOZ_ASSERT(fragment || isTemplateContents());
                 errStrayStartTag(name);
                 NS_HTML5_BREAK(starttagloop);
               } else {
                 errFramesetStart();
                 detachFromParent(stack[1]->node);
                 while (currentPtr > 0) {
                   pop();
                 }
                 appendToCurrentNodeAndPushElement(elementName, attributes);
-                mode = NS_HTML5TREE_BUILDER_IN_FRAMESET;
+                mode = IN_FRAMESET;
                 attributes = nullptr;
                 NS_HTML5_BREAK(starttagloop);
               }
             } else {
               errStrayStartTag(name);
               NS_HTML5_BREAK(starttagloop);
             }
           }
-          case NS_HTML5TREE_BUILDER_PRE_OR_LISTING:
-          case NS_HTML5TREE_BUILDER_LI:
-          case NS_HTML5TREE_BUILDER_DD_OR_DT:
-          case NS_HTML5TREE_BUILDER_BUTTON:
-          case NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET:
-          case NS_HTML5TREE_BUILDER_OBJECT:
-          case NS_HTML5TREE_BUILDER_TABLE:
-          case NS_HTML5TREE_BUILDER_AREA_OR_WBR:
-          case NS_HTML5TREE_BUILDER_BR:
-          case NS_HTML5TREE_BUILDER_EMBED:
-          case NS_HTML5TREE_BUILDER_IMG:
-          case NS_HTML5TREE_BUILDER_INPUT:
-          case NS_HTML5TREE_BUILDER_KEYGEN:
-          case NS_HTML5TREE_BUILDER_HR:
-          case NS_HTML5TREE_BUILDER_TEXTAREA:
-          case NS_HTML5TREE_BUILDER_XMP:
-          case NS_HTML5TREE_BUILDER_IFRAME:
-          case NS_HTML5TREE_BUILDER_SELECT: {
-            if (mode == NS_HTML5TREE_BUILDER_FRAMESET_OK && !(group == NS_HTML5TREE_BUILDER_INPUT && nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("hidden", attributes->getValue(nsHtml5AttributeName::ATTR_TYPE)))) {
+          case PRE_OR_LISTING:
+          case LI:
+          case DD_OR_DT:
+          case BUTTON:
+          case MARQUEE_OR_APPLET:
+          case OBJECT:
+          case TABLE:
+          case AREA_OR_WBR:
+          case BR:
+          case EMBED:
+          case IMG:
+          case INPUT:
+          case KEYGEN:
+          case HR:
+          case TEXTAREA:
+          case XMP:
+          case IFRAME:
+          case SELECT: {
+            if (mode == FRAMESET_OK &&
+                !(group == INPUT &&
+                  nsHtml5Portability::
+                    lowerCaseLiteralEqualsIgnoreAsciiCaseString(
+                      "hidden",
+                      attributes->getValue(nsHtml5AttributeName::ATTR_TYPE)))) {
               framesetOk = false;
-              mode = NS_HTML5TREE_BUILDER_IN_BODY;
+              mode = IN_BODY;
             }
           }
           default:
             ; // fall through
         }
       }
-      case NS_HTML5TREE_BUILDER_IN_BODY: {
+      case IN_BODY: {
         for (; ; ) {
           switch(group) {
-            case NS_HTML5TREE_BUILDER_HTML: {
+            case HTML: {
               errStrayStartTag(name);
               if (!fragment && !isTemplateContents()) {
                 addAttributesToHtml(attributes);
                 attributes = nullptr;
               }
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_BASE:
-            case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND:
-            case NS_HTML5TREE_BUILDER_META:
-            case NS_HTML5TREE_BUILDER_STYLE:
-            case NS_HTML5TREE_BUILDER_SCRIPT:
-            case NS_HTML5TREE_BUILDER_TITLE:
-            case NS_HTML5TREE_BUILDER_TEMPLATE: {
+            case BASE:
+            case LINK_OR_BASEFONT_OR_BGSOUND:
+            case META:
+            case STYLE:
+            case SCRIPT:
+            case TITLE:
+            case TEMPLATE: {
               NS_HTML5_BREAK(inbodyloop);
             }
-            case NS_HTML5TREE_BUILDER_BODY: {
-              if (!currentPtr || stack[1]->getGroup() != NS_HTML5TREE_BUILDER_BODY || isTemplateContents()) {
+            case BODY: {
+              if (!currentPtr || stack[1]->getGroup() != BODY ||
+                  isTemplateContents()) {
                 MOZ_ASSERT(fragment || isTemplateContents());
                 errStrayStartTag(name);
                 NS_HTML5_BREAK(starttagloop);
               }
               errFooSeenWhenFooOpen(name);
               framesetOk = false;
-              if (mode == NS_HTML5TREE_BUILDER_FRAMESET_OK) {
-                mode = NS_HTML5TREE_BUILDER_IN_BODY;
+              if (mode == FRAMESET_OK) {
+                mode = IN_BODY;
               }
               if (addAttributesToBody(attributes)) {
                 attributes = nullptr;
               }
               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_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY: {
+            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_DIALOG_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY: {
               implicitlyCloseP();
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6: {
+            case 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) {
+              if (stack[currentPtr]->getGroup() ==
+                  H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6) {
                 errHeadingWhenHeadingOpen();
                 pop();
               }
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_FIELDSET: {
+            case FIELDSET: {
               implicitlyCloseP();
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_PRE_OR_LISTING: {
+            case PRE_OR_LISTING: {
               implicitlyCloseP();
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               needToDropLF = true;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_FORM: {
+            case FORM: {
               if (!!formPointer && !isTemplateContents()) {
                 errFormWhenFormOpen();
                 NS_HTML5_BREAK(starttagloop);
               } else {
                 implicitlyCloseP();
                 appendToCurrentNodeAndPushFormElementMayFoster(attributes);
                 attributes = nullptr;
                 NS_HTML5_BREAK(starttagloop);
               }
             }
-            case NS_HTML5TREE_BUILDER_LI:
-            case NS_HTML5TREE_BUILDER_DD_OR_DT: {
+            case LI:
+            case DD_OR_DT: {
               eltPos = currentPtr;
               for (; ; ) {
                 nsHtml5StackNode* node = stack[eltPos];
                 if (node->getGroup() == group) {
                   generateImpliedEndTagsExceptFor(node->name);
                   if (!!MOZ_UNLIKELY(mViewSource) && eltPos != currentPtr) {
                     errUnclosedElementsImplied(eltPos, name);
                   }
@@ -1111,24 +1135,25 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
                 }
                 eltPos--;
               }
               implicitlyCloseP();
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_PLAINTEXT: {
+            case PLAINTEXT: {
               implicitlyCloseP();
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
-              tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_PLAINTEXT, elementName);
+              tokenizer->setStateAndEndTagExpectation(
+                nsHtml5Tokenizer::PLAINTEXT, elementName);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_A: {
+            case A: {
               int32_t activeAPos = findInListOfActiveFormattingElementsContainsBetweenEndAndLastMarker(nsHtml5Atoms::a);
               if (activeAPos != -1) {
                 errFooSeenWhenFooOpen(name);
                 nsHtml5StackNode* activeA = listOfActiveFormattingElements[activeAPos];
                 activeA->retain();
                 adoptionAgencyEndTag(nsHtml5Atoms::a);
                 removeFromStack(activeA);
                 activeAPos = findInListOfActiveFormattingElements(activeA);
@@ -1137,114 +1162,115 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
                 }
                 activeA->release();
               }
               reconstructTheActiveFormattingElements();
               appendToCurrentNodeAndPushFormattingElementMayFoster(elementName, attributes);
               attributes = nullptr;
               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: {
+            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->getName(), attributes);
               appendToCurrentNodeAndPushFormattingElementMayFoster(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_NOBR: {
+            case NOBR: {
               reconstructTheActiveFormattingElements();
-              if (NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK != findLastInScope(nsHtml5Atoms::nobr)) {
+              if (nsHtml5TreeBuilder::NOT_FOUND_ON_STACK !=
+                  findLastInScope(nsHtml5Atoms::nobr)) {
                 errFooSeenWhenFooOpen(name);
                 adoptionAgencyEndTag(nsHtml5Atoms::nobr);
                 reconstructTheActiveFormattingElements();
               }
               appendToCurrentNodeAndPushFormattingElementMayFoster(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_BUTTON: {
+            case BUTTON: {
               eltPos = findLastInScope(name);
-              if (eltPos != NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+              if (eltPos != nsHtml5TreeBuilder::NOT_FOUND_ON_STACK) {
                 errFooSeenWhenFooOpen(name);
                 generateImpliedEndTags();
                 if (!!MOZ_UNLIKELY(mViewSource) && !isCurrent(name)) {
                   errUnclosedElementsImplied(eltPos, name);
                 }
                 while (currentPtr >= eltPos) {
                   pop();
                 }
                 NS_HTML5_CONTINUE(starttagloop);
               } else {
                 reconstructTheActiveFormattingElements();
                 appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
                 attributes = nullptr;
                 NS_HTML5_BREAK(starttagloop);
               }
             }
-            case NS_HTML5TREE_BUILDER_OBJECT: {
+            case OBJECT: {
               reconstructTheActiveFormattingElements();
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
               insertMarker();
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET: {
+            case MARQUEE_OR_APPLET: {
               reconstructTheActiveFormattingElements();
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               insertMarker();
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_TABLE: {
+            case TABLE: {
               if (!quirks) {
                 implicitlyCloseP();
               }
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
-              mode = NS_HTML5TREE_BUILDER_IN_TABLE;
+              mode = IN_TABLE;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_BR:
-            case NS_HTML5TREE_BUILDER_EMBED:
-            case NS_HTML5TREE_BUILDER_AREA_OR_WBR: {
+            case BR:
+            case EMBED:
+            case AREA_OR_WBR: {
               reconstructTheActiveFormattingElements();
             }
 #ifdef ENABLE_VOID_MENUITEM
-            case NS_HTML5TREE_BUILDER_MENUITEM:
+            case MENUITEM:
 #endif
-            case NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE_OR_TRACK: {
+            case PARAM_OR_SOURCE_OR_TRACK: {
               appendVoidElementToCurrentMayFoster(elementName, attributes);
               selfClosing = false;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_HR: {
+            case HR: {
               implicitlyCloseP();
               appendVoidElementToCurrentMayFoster(elementName, attributes);
               selfClosing = false;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_IMAGE: {
+            case IMAGE: {
               errImage();
               elementName = nsHtml5ElementName::ELT_IMG;
               NS_HTML5_CONTINUE(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_IMG:
-            case NS_HTML5TREE_BUILDER_KEYGEN:
-            case NS_HTML5TREE_BUILDER_INPUT: {
+            case IMG:
+            case KEYGEN:
+            case INPUT: {
               reconstructTheActiveFormattingElements();
               appendVoidElementToCurrentMayFoster(name, attributes, formPointer);
               selfClosing = false;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_ISINDEX: {
+            case ISINDEX: {
               errIsindex();
               if (!!formPointer && !isTemplateContents()) {
                 NS_HTML5_BREAK(starttagloop);
               }
               implicitlyCloseP();
               nsHtml5HtmlAttributes* formAttrs = new nsHtml5HtmlAttributes(0);
               int32_t actionIndex = attributes->getIndex(nsHtml5AttributeName::ATTR_ACTION);
               if (actionIndex > -1) {
@@ -1281,659 +1307,667 @@ nsHtml5TreeBuilder::startTag(nsHtml5Elem
               appendVoidElementToCurrentMayFoster(nsHtml5ElementName::ELT_HR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
               pop();
               if (!isTemplateContents()) {
                 formPointer = nullptr;
               }
               selfClosing = false;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_TEXTAREA: {
+            case TEXTAREA: {
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
-              tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RCDATA, elementName);
+              tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::RCDATA,
+                                                      elementName);
               originalMode = mode;
-              mode = NS_HTML5TREE_BUILDER_TEXT;
+              mode = TEXT;
               needToDropLF = true;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_XMP: {
+            case XMP: {
               implicitlyCloseP();
               reconstructTheActiveFormattingElements();
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               originalMode = mode;
-              mode = NS_HTML5TREE_BUILDER_TEXT;
-              tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
+              mode = TEXT;
+              tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::RAWTEXT,
+                                                      elementName);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_NOSCRIPT: {
+            case NOSCRIPT: {
               if (!scriptingEnabled) {
                 reconstructTheActiveFormattingElements();
                 appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
                 attributes = nullptr;
                 NS_HTML5_BREAK(starttagloop);
               } else {
               }
             }
-            case NS_HTML5TREE_BUILDER_NOFRAMES:
-            case NS_HTML5TREE_BUILDER_IFRAME:
-            case NS_HTML5TREE_BUILDER_NOEMBED: {
+            case NOFRAMES:
+            case IFRAME:
+            case NOEMBED: {
               startTagGenericRawText(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_SELECT: {
+            case SELECT: {
               reconstructTheActiveFormattingElements();
               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;
+                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;
                   break;
                 }
                 default: {
-                  mode = NS_HTML5TREE_BUILDER_IN_SELECT;
+                  mode = IN_SELECT;
                   break;
                 }
               }
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_OPTGROUP:
-            case NS_HTML5TREE_BUILDER_OPTION: {
+            case OPTGROUP:
+            case OPTION: {
               if (isCurrent(nsHtml5Atoms::option)) {
                 pop();
               }
               reconstructTheActiveFormattingElements();
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_RB_OR_RTC: {
+            case RB_OR_RTC: {
               eltPos = findLastInScope(nsHtml5Atoms::ruby);
-              if (eltPos != NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+              if (eltPos != NOT_FOUND_ON_STACK) {
                 generateImpliedEndTags();
               }
               if (eltPos != currentPtr) {
-                if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+                if (eltPos == NOT_FOUND_ON_STACK) {
                   errStartTagSeenWithoutRuby(name);
                 } else {
                   errUnclosedChildrenInRuby();
                 }
               }
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_RT_OR_RP: {
+            case RT_OR_RP: {
               eltPos = findLastInScope(nsHtml5Atoms::ruby);
-              if (eltPos != NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+              if (eltPos != NOT_FOUND_ON_STACK) {
                 generateImpliedEndTagsExceptFor(nsHtml5Atoms::rtc);
               }
               if (eltPos != currentPtr) {
                 if (!isCurrent(nsHtml5Atoms::rtc)) {
-                  if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+                  if (eltPos == NOT_FOUND_ON_STACK) {
                     errStartTagSeenWithoutRuby(name);
                   } else {
                     errUnclosedChildrenInRuby();
                   }
                 }
               }
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_MATH: {
+            case MATH: {
               reconstructTheActiveFormattingElements();
               attributes->adjustForMath();
               if (selfClosing) {
                 appendVoidElementToCurrentMayFosterMathML(elementName, attributes);
                 selfClosing = false;
               } else {
                 appendToCurrentNodeAndPushElementMayFosterMathML(elementName, attributes);
               }
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_SVG: {
+            case SVG: {
               reconstructTheActiveFormattingElements();
               attributes->adjustForSvg();
               if (selfClosing) {
                 appendVoidElementToCurrentMayFosterSVG(elementName, attributes);
                 selfClosing = false;
               } else {
                 appendToCurrentNodeAndPushElementMayFosterSVG(elementName, attributes);
               }
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_CAPTION:
-            case NS_HTML5TREE_BUILDER_COL:
-            case NS_HTML5TREE_BUILDER_COLGROUP:
-            case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT:
-            case NS_HTML5TREE_BUILDER_TR:
-            case NS_HTML5TREE_BUILDER_TD_OR_TH:
-            case NS_HTML5TREE_BUILDER_FRAME:
-            case NS_HTML5TREE_BUILDER_FRAMESET:
-            case NS_HTML5TREE_BUILDER_HEAD: {
+            case CAPTION:
+            case COL:
+            case COLGROUP:
+            case TBODY_OR_THEAD_OR_TFOOT:
+            case TR:
+            case TD_OR_TH:
+            case FRAME:
+            case FRAMESET:
+            case HEAD: {
               errStrayStartTag(name);
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_OUTPUT: {
+            case OUTPUT: {
               reconstructTheActiveFormattingElements();
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes, formPointer);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
             default: {
               reconstructTheActiveFormattingElements();
               appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
           }
         }
         inbodyloop_end: ;
       }
-      case NS_HTML5TREE_BUILDER_IN_HEAD: {
+      case IN_HEAD: {
         for (; ; ) {
           switch(group) {
-            case NS_HTML5TREE_BUILDER_HTML: {
+            case HTML: {
               errStrayStartTag(name);
               if (!fragment && !isTemplateContents()) {
                 addAttributesToHtml(attributes);
                 attributes = nullptr;
               }
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_BASE:
-            case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND: {
+            case BASE:
+            case LINK_OR_BASEFONT_OR_BGSOUND: {
               appendVoidElementToCurrentMayFoster(elementName, attributes);
               selfClosing = false;
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_META: {
+            case META: {
               NS_HTML5_BREAK(inheadloop);
             }
-            case NS_HTML5TREE_BUILDER_TITLE: {
+            case TITLE: {
               startTagTitleInHead(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_NOSCRIPT: {
+            case NOSCRIPT: {
               if (scriptingEnabled) {
                 appendToCurrentNodeAndPushElement(elementName, attributes);
                 originalMode = mode;
-                mode = NS_HTML5TREE_BUILDER_TEXT;
-                tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
+                mode = TEXT;
+                tokenizer->setStateAndEndTagExpectation(
+                  nsHtml5Tokenizer::RAWTEXT, elementName);
               } else {
                 appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
-                mode = NS_HTML5TREE_BUILDER_IN_HEAD_NOSCRIPT;
+                mode = IN_HEAD_NOSCRIPT;
               }
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_SCRIPT: {
+            case SCRIPT: {
               startTagScriptInHead(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_STYLE:
-            case NS_HTML5TREE_BUILDER_NOFRAMES: {
+            case STYLE:
+            case NOFRAMES: {
               startTagGenericRawText(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_HEAD: {
+            case HEAD: {
               errFooSeenWhenFooOpen(name);
               NS_HTML5_BREAK(starttagloop);
             }
-            case NS_HTML5TREE_BUILDER_TEMPLATE: {
+            case TEMPLATE: {
               startTagTemplateInHead(elementName, attributes);
               attributes = nullptr;
               NS_HTML5_BREAK(starttagloop);
             }
             default: {
               pop();
-              mode = NS_HTML5TREE_BUILDER_AFTER_HEAD;
+              mode = AFTER_HEAD;
               NS_HTML5_CONTINUE(starttagloop);
             }
           }
         }
         inheadloop_end: ;
       }
-      case NS_HTML5TREE_BUILDER_IN_HEAD_NOSCRIPT: {
+      case IN_HEAD_NOSCRIPT: {
         switch(group) {
-          case NS_HTML5TREE_BUILDER_HTML: {
+          case HTML: {
             errStrayStartTag(name);
             if (!fragment && !isTemplateContents()) {
               addAttributesToHtml(attributes);
               attributes = nullptr;
             }
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND: {
+          case LINK_OR_BASEFONT_OR_BGSOUND: {
             appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = false;
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_META: {
+          case META: {
             checkMetaCharset(attributes);
             appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = false;
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_STYLE:
-          case NS_HTML5TREE_BUILDER_NOFRAMES: {
+          case STYLE:
+          case NOFRAMES: {
             appendToCurrentNodeAndPushElement(elementName, attributes);
             originalMode = mode;
-            mode = NS_HTML5TREE_BUILDER_TEXT;
-            tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, elementName);
+            mode = TEXT;
+            tokenizer->setStateAndEndTagExpectation(nsHtml5Tokenizer::RAWTEXT,
+                                                    elementName);
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_HEAD: {
+          case HEAD: {
             errFooSeenWhenFooOpen(name);
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_NOSCRIPT: {
+          case NOSCRIPT: {
             errFooSeenWhenFooOpen(name);
             NS_HTML5_BREAK(starttagloop);
           }
           default: {
             errBadStartTagInHead(name);
             pop();
-            mode = NS_HTML5TREE_BUILDER_IN_HEAD;
+            mode = IN_HEAD;
             continue;
           }
         }
       }
-      case NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP: {
+      case IN_COLUMN_GROUP: {
         switch(group) {
-          case NS_HTML5TREE_BUILDER_HTML: {
+          case HTML: {
             errStrayStartTag(name);
             if (!fragment && !isTemplateContents()) {
               addAttributesToHtml(attributes);
               attributes = nullptr;
             }
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_COL: {
+          case COL: {
             appendVoidElementToCurrentMayFoster(elementName, attributes);
             selfClosing = false;
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_TEMPLATE: {
+          case TEMPLATE: {
             startTagTemplateInHead(elementName, attributes);
             attributes = nullptr;
             NS_HTML5_BREAK(starttagloop);
           }
           default: {
-            if (!currentPtr || stack[currentPtr]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE) {
+            if (!currentPtr || stack[currentPtr]->getGroup() == TEMPLATE) {
               MOZ_ASSERT(fragment || isTemplateContents());
               errGarbageInColgroup();
               NS_HTML5_BREAK(starttagloop);
             }
             pop();
-            mode = NS_HTML5TREE_BUILDER_IN_TABLE;
+            mode = IN_TABLE;
             continue;
           }
         }
       }
-      case NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE: {
+      case IN_SELECT_IN_TABLE: {
         switch(group) {
-          case NS_HTML5TREE_BUILDER_CAPTION:
-          case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT:
-          case NS_HTML5TREE_BUILDER_TR:
-          case NS_HTML5TREE_BUILDER_TD_OR_TH:
-          case NS_HTML5TREE_BUILDER_TABLE: {
+          case CAPTION:
+          case TBODY_OR_THEAD_OR_TFOOT:
+          case TR:
+          case TD_OR_TH:
+          case TABLE: {
             errStartTagWithSelectOpen(name);
             eltPos = findLastInTableScope(nsHtml5Atoms::select);
-            if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+            if (eltPos == nsHtml5TreeBuilder::NOT_FOUND_ON_STACK) {
               MOZ_ASSERT(fragment);
               NS_HTML5_BREAK(starttagloop);
             }
             while (currentPtr >= eltPos) {
               pop();
             }
             resetTheInsertionMode();
             continue;
           }
           default:
             ; // fall through
         }
       }
-      case NS_HTML5TREE_BUILDER_IN_SELECT: {
+      case IN_SELECT: {
         switch(group) {
-          case NS_HTML5TREE_BUILDER_HTML: {
+          case HTML: {
             errStrayStartTag(name);
             if (!fragment) {
               addAttributesToHtml(attributes);
               attributes = nullptr;
             }
             NS_HTML5_BREAK(starttagloop);
           }
-          case NS_HTML5TREE_BUILDER_OPTION: {
+          case OPTION: {
             if (isCurrent(nsHtml5Atoms::option)) {