Merge remote-tracking branch 'origin/master' into custom

This commit is contained in:
Roy Tam 2020-01-31 07:59:13 +08:00
commit c7bc87cff9
313 changed files with 18135 additions and 13978 deletions

View file

@ -1,13 +1,13 @@
If this is your first time building the HTML5 parser, you need to execute the
following commands (from this directory) to accomplish the translation:
make translate # perform the Java-to-C++ translation from the remote
make translate # perform the Java-to-C++ translation from the remote
# sources
make named_characters # Generate tables for named character tokenization
If you make changes to the translator or the javaparser, you can rebuild by
retyping 'make' in this directory. If you make changes to the HTML5 Java
implementation, you can retranslate the Java sources from the htmlparser
implementation, you can retranslate the Java sources from the htmlparser
repository by retyping 'make translate' in this directory.
The makefile supports the following targets:
@ -36,6 +36,43 @@ clean-javasrc:
clean:
Runs clean-javaparser, clean-htmlparser, and clean-javasrc.
## How to add an attribute
# starting from the root of a UXP checkout
cd parser/html/java/htmlparser/src/
$EDITOR nu/validator/htmlparser/impl/AttributeName.java
# Search for the word "uncomment" and uncomment stuff according to the comments that talk about uncommenting
# Duplicate the declaration a normal attribute (nothings special in SVG mode, etc.). Let's use "alt", since it's the first one.
# In the duplicate, replace ALT with the new name in all caps and "alt" with the new name in quotes in lower case.
# Search for "ALT,", duplicate that line and change the duplicate to say the new name in all caps followed by comma.
# Save.
javac nu/validator/htmlparser/impl/AttributeName.java
java nu.validator.htmlparser.impl.AttributeName
# Copy and paste the output into nu/validator/htmlparser/impl/AttributeName.java replacing the text below the comment "START GENERATED CODE" and above the very last "}".
# Recomment the bits that you uncommented earlier.
# Save.
cd ../.. # Back to parser/html/java/
make translate
## How to add an element
# First, add an entry to parser/htmlparser/nsHTMLTagList.h or dom/svg/SVGTagList.h!
# Then, starting from the root of a UXP checkout
cd parser/html/java/htmlparser/src/
$EDITOR nu/validator/htmlparser/impl/ElementName.java
# Search for the word "uncomment" and uncomment stuff according to the comments that talk about uncommenting
# Duplicate the declaration a normal element. Let's use "bdo", since it's the first normal one.
# In the duplicate, replace BDO with the new name in all caps and "bdo" with the new name in quotes in lower case (twice).
# Search for "BDO,", duplicate that line and change the duplicate to say the new name in all caps followed by comma.
# Save.
javac nu/validator/htmlparser/impl/ElementName.java
java nu.validator.htmlparser.impl.ElementName ../../../../../parser/htmlparser/nsHTMLTagList.h ../../../../../dom/svg/SVGTagList.h
# Copy and paste the output into nu/validator/htmlparser/impl/ElementName.java replacing the text below the comment "START GENERATED CODE" and above the very last "}".
# Recomment the bits that you uncommented earlier.
# Save.
cd ../.. # Back to parser/html/java/
make translate
Ben Newman (23 September 2009)
Henri Sivonen (11 August 2016)
Matt A. Tobin (16 January 2020)

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2017 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* 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.
*/
/**
* Applied to an integer type to generate the unsigned variant in C++.
*/
package nu.validator.htmlparser.annotation;
public @interface Creator {
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2017 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* 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.
*/
/**
* Applied to an integer type to generate the unsigned variant in C++.
*/
package nu.validator.htmlparser.annotation;
public @interface HtmlCreator {
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2017 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* 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.
*/
/**
* Applied to an integer type to generate the unsigned variant in C++.
*/
package nu.validator.htmlparser.annotation;
public @interface SvgCreator {
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2017 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* 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.
*/
/**
* Applied to an integer type to generate the unsigned variant in C++.
*/
package nu.validator.htmlparser.annotation;
public @interface Unsigned {
}

View file

@ -22,10 +22,10 @@
package nu.validator.htmlparser.impl;
import nu.validator.htmlparser.annotation.NoLength;
import org.xml.sax.SAXException;
import nu.validator.htmlparser.annotation.NoLength;
/**
* A common superclass for tree builders that coalesce their text nodes.
*
@ -48,13 +48,6 @@ public abstract class CoalescingTreeBuilder<T> extends TreeBuilder<T> {
appendCharacters(parent, new String(buf, start, length));
}
/**
* @see nu.validator.htmlparser.impl.TreeBuilder#appendIsindexPrompt(java.lang.Object)
*/
@Override protected void appendIsindexPrompt(T parent) throws SAXException {
appendCharacters(parent, "This is a searchable index. Enter search keywords: ");
}
protected abstract void appendCharacters(T parent, String text) throws SAXException;
/**

View file

@ -22,17 +22,17 @@
package nu.validator.htmlparser.impl;
import java.util.HashMap;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import nu.validator.htmlparser.annotation.Inline;
import nu.validator.htmlparser.annotation.NoLength;
import nu.validator.htmlparser.common.TokenHandler;
import nu.validator.htmlparser.common.TransitionHandler;
import nu.validator.htmlparser.common.XmlViolationPolicy;
import java.util.HashMap;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class ErrorReportingTokenizer extends Tokenizer {
/**
@ -388,7 +388,7 @@ public class ErrorReportingTokenizer extends Tokenizer {
&& ElementName.IFRAME != endTagExpectation) {
err((stateSave == Tokenizer.DATA ? "CDATA" : "RCDATA")
+ " element \u201C"
+ endTagExpectation.name
+ endTagExpectation.getName()
+ "\u201D contained the string \u201C</\u201D, but it was not the start of the end tag. (HTML4-only error)");
}
}

View file

@ -25,7 +25,9 @@
package nu.validator.htmlparser.impl;
import nu.validator.htmlparser.annotation.Auto;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import nu.validator.htmlparser.annotation.IdType;
import nu.validator.htmlparser.annotation.Local;
import nu.validator.htmlparser.annotation.NsUri;
@ -34,9 +36,6 @@ import nu.validator.htmlparser.annotation.QName;
import nu.validator.htmlparser.common.Interner;
import nu.validator.htmlparser.common.XmlViolationPolicy;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* Be careful with this class. QName is the name in from HTML tokenization.
* Otherwise, please refer to the interface doc.
@ -46,14 +45,10 @@ import org.xml.sax.SAXException;
*/
public final class HtmlAttributes implements Attributes {
// [NOCPP[
private static final AttributeName[] EMPTY_ATTRIBUTENAMES = new AttributeName[0];
private static final String[] EMPTY_STRINGS = new String[0];
// ]NOCPP]
public static final HtmlAttributes EMPTY_ATTRIBUTES = new HtmlAttributes(
AttributeName.HTML);
@ -61,13 +56,9 @@ public final class HtmlAttributes implements Attributes {
private int length;
private @Auto AttributeName[] names;
private AttributeName[] names;
private @Auto String[] values; // XXX perhaps make this @NoLength?
// CPPONLY: private @Auto int[] lines; // XXX perhaps make this @NoLength?
// [NOCPP[
private String[] values;
private String idValue;
@ -77,21 +68,15 @@ public final class HtmlAttributes implements Attributes {
private String[] xmlnsValues;
// ]NOCPP]
public HtmlAttributes(int mode) {
this.mode = mode;
this.length = 0;
/*
* The length of 5 covers covers 98.3% of elements
* according to Hixie, but lets round to the next power of two for
* jemalloc.
* according to Hixie.
*/
this.names = new AttributeName[8];
this.values = new String[8];
// CPPONLY: this.lines = new int[8];
// [NOCPP[
this.names = new AttributeName[5];
this.values = new String[5];
this.idValue = null;
@ -101,25 +86,6 @@ public final class HtmlAttributes implements Attributes {
this.xmlnsValues = HtmlAttributes.EMPTY_STRINGS;
// ]NOCPP]
}
/*
public HtmlAttributes(HtmlAttributes other) {
this.mode = other.mode;
this.length = other.length;
this.names = new AttributeName[other.length];
this.values = new String[other.length];
// [NOCPP[
this.idValue = other.idValue;
this.xmlnsLength = other.xmlnsLength;
this.xmlnsNames = new AttributeName[other.xmlnsLength];
this.xmlnsValues = new String[other.xmlnsLength];
// ]NOCPP]
}
*/
void destructor() {
clear(0);
}
/**
@ -161,7 +127,6 @@ public final class HtmlAttributes implements Attributes {
* @return the local name at index
*/
public @Local String getLocalNameNoBoundsCheck(int index) {
// CPPONLY: assert index < length && index >= 0: "Index out of bounds";
return names[index].getLocal(mode);
}
@ -171,7 +136,6 @@ public final class HtmlAttributes implements Attributes {
* @return the namespace URI at index
*/
public @NsUri String getURINoBoundsCheck(int index) {
// CPPONLY: assert index < length && index >= 0: "Index out of bounds";
return names[index].getUri(mode);
}
@ -181,7 +145,6 @@ public final class HtmlAttributes implements Attributes {
* @return the namespace prefix at index
*/
public @Prefix String getPrefixNoBoundsCheck(int index) {
// CPPONLY: assert index < length && index >= 0: "Index out of bounds";
return names[index].getPrefix(mode);
}
@ -191,7 +154,6 @@ public final class HtmlAttributes implements Attributes {
* @return the attribute value at index
*/
public String getValueNoBoundsCheck(int index) {
// CPPONLY: assert index < length && index >= 0: "Index out of bounds";
return values[index];
}
@ -201,21 +163,9 @@ public final class HtmlAttributes implements Attributes {
* @return the attribute name at index
*/
public AttributeName getAttributeNameNoBoundsCheck(int index) {
// CPPONLY: assert index < length && index >= 0: "Index out of bounds";
return names[index];
}
// CPPONLY: /**
// CPPONLY: * Obtains a line number without bounds check.
// CPPONLY: * @param index a valid attribute index
// CPPONLY: * @return the line number at index or -1 if unknown
// CPPONLY: */
// CPPONLY: public int getLineNoBoundsCheck(int index) {
// CPPONLY: assert index < length && index >= 0: "Index out of bounds";
// CPPONLY: return lines[index];
// CPPONLY: }
// [NOCPP[
/**
* Variant of <code>getQName(int index)</code> without bounds check.
@ -404,15 +354,9 @@ public final class HtmlAttributes implements Attributes {
}
}
// ]NOCPP]
void addAttribute(AttributeName name, String value
// [NOCPP[
, XmlViolationPolicy xmlnsPolicy
// ]NOCPP]
// CPPONLY: , int line
) throws SAXException {
// [NOCPP[
if (name == AttributeName.ID) {
idValue = value;
}
@ -441,8 +385,6 @@ public final class HtmlAttributes implements Attributes {
}
}
// ]NOCPP]
if (names.length == length) {
int newLen = length << 1; // The first growth covers virtually
// 100% of elements according to
@ -453,53 +395,25 @@ public final class HtmlAttributes implements Attributes {
String[] newValues = new String[newLen];
System.arraycopy(values, 0, newValues, 0, values.length);
values = newValues;
// CPPONLY: int[] newLines = new int[newLen];
// CPPONLY: System.arraycopy(lines, 0, newLines, 0, lines.length);
// CPPONLY: lines = newLines;
}
names[length] = name;
values[length] = value;
// CPPONLY: lines[length] = line;
length++;
}
void clear(int m) {
for (int i = 0; i < length; i++) {
names[i].release();
names[i] = null;
Portability.releaseString(values[i]);
values[i] = null;
}
length = 0;
mode = m;
// [NOCPP[
idValue = null;
for (int i = 0; i < xmlnsLength; i++) {
xmlnsNames[i] = null;
xmlnsValues[i] = null;
}
xmlnsLength = 0;
// ]NOCPP]
}
/**
* This is used in C++ to release special <code>isindex</code>
* attribute values whose ownership is not transferred.
*/
void releaseValue(int i) {
Portability.releaseString(values[i]);
}
/**
* This is only used for <code>AttributeName</code> ownership transfer
* in the isindex case to avoid freeing custom names twice in C++.
*/
void clearWithoutReleasingContents() {
for (int i = 0; i < length; i++) {
names[i] = null;
values[i] = null;
}
length = 0;
}
boolean contains(AttributeName name) {
@ -508,13 +422,11 @@ public final class HtmlAttributes implements Attributes {
return true;
}
}
// [NOCPP[
for (int i = 0; i < xmlnsLength; i++) {
if (name.equalsAnother(xmlnsNames[i])) {
return true;
}
}
// ]NOCPP]
return false;
}
@ -529,27 +441,20 @@ public final class HtmlAttributes implements Attributes {
public HtmlAttributes cloneAttributes(Interner interner)
throws SAXException {
assert (length == 0
// [NOCPP[
&& xmlnsLength == 0
// ]NOCPP]
)
|| mode == 0 || mode == 3;
HtmlAttributes clone = new HtmlAttributes(0);
for (int i = 0; i < length; i++) {
clone.addAttribute(names[i].cloneAttributeName(interner),
Portability.newStringFromString(values[i])
// [NOCPP[
clone.addAttribute(names[i],
values[i]
, XmlViolationPolicy.ALLOW
// ]NOCPP]
// CPPONLY: , lines[i]
);
}
// [NOCPP[
for (int i = 0; i < xmlnsLength; i++) {
clone.addAttribute(xmlnsNames[i], xmlnsValues[i],
XmlViolationPolicy.ALLOW);
}
// ]NOCPP]
return clone; // XXX!!!
}
@ -568,9 +473,10 @@ public final class HtmlAttributes implements Attributes {
for (int j = 0; j < otherLength; j++) {
if (ownLocal == other.names[j].getLocal(AttributeName.HTML)) {
found = true;
if (!Portability.stringEqualsString(values[i], other.values[j])) {
if (!values[i].equals(other.values[j])) {
return false;
}
break;
}
}
if (!found) {
@ -579,9 +485,7 @@ public final class HtmlAttributes implements Attributes {
}
return true;
}
// [NOCPP[
void processNonNcNames(TreeBuilder<?> treeBuilder, XmlViolationPolicy namePolicy) throws SAXException {
for (int i = 0; i < length; i++) {
AttributeName attName = names[i];
@ -613,8 +517,4 @@ public final class HtmlAttributes implements Attributes {
}
}
}
// ]NOCPP]
}

View file

@ -45,6 +45,11 @@ final class StackNode<T> {
private int refcount = 1;
/*
* Only valid for formatting elements
*/
// CPPONLY: private @HtmlCreator Object htmlCreator;
// [NOCPP[
private final TaintableLocatorImpl locator;
@ -87,6 +92,10 @@ final class StackNode<T> {
// ]NOCPP]
// CPPONLY: public @HtmlCreator Object getHtmlCreator() {
// CPPONLY: return htmlCreator;
// CPPONLY: }
/**
* Constructor for copying. This doesn't take another <code>StackNode</code>
* because in C++ the caller is reponsible for reobtaining the local names
@ -100,9 +109,10 @@ final class StackNode<T> {
* @param attributes
*/
StackNode(int flags, @NsUri String ns, @Local String name, T node,
@Local String popName, HtmlAttributes attributes
@Local String popName, HtmlAttributes attributes,
// CPPONLY: @HtmlCreator Object htmlCreator
// [NOCPP[
, TaintableLocatorImpl locator
TaintableLocatorImpl locator
// ]NOCPP]
) {
this.flags = flags;
@ -112,6 +122,10 @@ final class StackNode<T> {
this.node = node;
this.attributes = attributes;
this.refcount = 1;
/*
* Need to track creator for formatting elements when copying.
*/
// CPPONLY: this.htmlCreator = htmlCreator;
// [NOCPP[
this.locator = locator;
// ]NOCPP]
@ -129,13 +143,17 @@ final class StackNode<T> {
// ]NOCPP]
) {
this.flags = elementName.getFlags();
this.name = elementName.name;
this.popName = elementName.name;
this.name = elementName.getName();
this.popName = elementName.getName();
this.ns = "http://www.w3.org/1999/xhtml";
this.node = node;
this.attributes = null;
this.refcount = 1;
assert !elementName.isCustom() : "Don't use this constructor for custom elements.";
assert elementName.isInterned() : "Don't use this constructor for custom elements.";
/*
* Not used for formatting elements, so no need to track creator.
*/
// CPPONLY: this.htmlCreator = null;
// [NOCPP[
this.locator = locator;
// ]NOCPP]
@ -154,13 +172,18 @@ final class StackNode<T> {
// ]NOCPP]
) {
this.flags = elementName.getFlags();
this.name = elementName.name;
this.popName = elementName.name;
this.name = elementName.getName();
this.popName = elementName.getName();
this.ns = "http://www.w3.org/1999/xhtml";
this.node = node;
this.attributes = attributes;
this.refcount = 1;
assert !elementName.isCustom() : "Don't use this constructor for custom elements.";
assert elementName.isInterned() : "Don't use this constructor for custom elements.";
/*
* Need to track creator for formatting elements in order to be able
* to clone them.
*/
// CPPONLY: this.htmlCreator = elementName.getHtmlCreator();
// [NOCPP[
this.locator = locator;
// ]NOCPP]
@ -179,12 +202,16 @@ final class StackNode<T> {
// ]NOCPP]
) {
this.flags = elementName.getFlags();
this.name = elementName.name;
this.name = elementName.getName();
this.popName = popName;
this.ns = "http://www.w3.org/1999/xhtml";
this.node = node;
this.attributes = null;
this.refcount = 1;
/*
* Not used for formatting elements, so no need to track creator.
*/
// CPPONLY: this.htmlCreator = null;
// [NOCPP[
this.locator = locator;
// ]NOCPP]
@ -206,12 +233,16 @@ final class StackNode<T> {
// ]NOCPP]
) {
this.flags = prepareSvgFlags(elementName.getFlags());
this.name = elementName.name;
this.name = elementName.getName();
this.popName = popName;
this.ns = "http://www.w3.org/2000/svg";
this.node = node;
this.attributes = null;
this.refcount = 1;
/*
* Not used for formatting elements, so no need to track creator.
*/
// CPPONLY: this.htmlCreator = null;
// [NOCPP[
this.locator = locator;
// ]NOCPP]
@ -233,12 +264,16 @@ final class StackNode<T> {
) {
this.flags = prepareMathFlags(elementName.getFlags(),
markAsIntegrationPoint);
this.name = elementName.name;
this.name = elementName.getName();
this.popName = popName;
this.ns = "http://www.w3.org/1998/Math/MathML";
this.node = node;
this.attributes = null;
this.refcount = 1;
/*
* Not used for formatting elements, so no need to track creator.
*/
// CPPONLY: this.htmlCreator = null;
// [NOCPP[
this.locator = locator;
// ]NOCPP]

View file

@ -417,15 +417,31 @@ public class Tokenizer implements Locator {
protected boolean endTag;
/**
* The current tag token name.
* <code>true</code> iff the current element/attribute name contains
* a hyphen.
*/
private boolean containsHyphen;
/**
* The current tag token name. One of
* 1) null,
* 2) non-owning reference to nonInternedTagName
* 3) non-owning reference to a pre-interned ElementName
*/
private ElementName tagName = null;
/**
* The recycled ElementName instance for the non-pre-interned cases.
*/
private ElementName nonInternedTagName = null;
/**
* The current attribute name.
*/
protected AttributeName attributeName = null;
// CPPONLY: private AttributeName nonInternedAttributeName = null;
// [NOCPP[
/**
@ -519,8 +535,11 @@ public class Tokenizer implements Locator {
this.charRefBuf = new char[32];
this.bmpChar = new char[1];
this.astralChar = new char[2];
this.containsHyphen = false;
this.tagName = null;
this.nonInternedTagName = new ElementName();
this.attributeName = null;
// CPPONLY: this.nonInternedAttributeName = new AttributeName();
this.doctypeName = null;
this.publicIdentifier = null;
this.systemIdentifier = null;
@ -548,8 +567,11 @@ public class Tokenizer implements Locator {
this.charRefBuf = new char[32];
this.bmpChar = new char[1];
this.astralChar = new char[2];
this.containsHyphen = false;
this.tagName = null;
this.nonInternedTagName = new ElementName();
this.attributeName = null;
// CPPONLY: this.nonInternedAttributeName = new AttributeName();
this.doctypeName = null;
this.publicIdentifier = null;
this.systemIdentifier = null;
@ -710,6 +732,7 @@ public class Tokenizer implements Locator {
@Auto char[] asArray = Portability.newCharArrayFromLocal(endTagExpectation);
this.endTagExpectation = ElementName.elementNameByBuffer(asArray, 0,
asArray.length, interner);
assert this.endTagExpectation != null;
endTagExpectationToArray();
}
@ -1110,8 +1133,30 @@ public class Tokenizer implements Locator {
}
private void strBufToElementNameString() {
tagName = ElementName.elementNameByBuffer(strBuf, 0, strBufLen,
interner);
if (containsHyphen) {
// We've got a custom element or annotation-xml.
@Local String annotationName = ElementName.ANNOTATION_XML.getName();
if (Portability.localEqualsBuffer(annotationName, strBuf, 0, strBufLen)) {
tagName = ElementName.ANNOTATION_XML;
} else {
nonInternedTagName.setNameForNonInterned(Portability.newLocalNameFromBuffer(strBuf, 0, strBufLen,
interner)
// CPPONLY: , true
);
tagName = nonInternedTagName;
}
} else {
tagName = ElementName.elementNameByBuffer(strBuf, 0, strBufLen,
interner);
if (tagName == null) {
nonInternedTagName.setNameForNonInterned(Portability.newLocalNameFromBuffer(strBuf, 0, strBufLen,
interner)
// CPPONLY: , false
);
tagName = nonInternedTagName;
}
}
containsHyphen = false;
clearStrBufAfterUse();
}
@ -1144,7 +1189,6 @@ public class Tokenizer implements Locator {
tokenHandler.startTag(tagName, attrs, selfClosing);
// CPPONLY: }
}
tagName.release();
tagName = null;
if (newAttributesEachTime) {
attributes = null;
@ -1159,11 +1203,17 @@ public class Tokenizer implements Locator {
}
private void attributeNameComplete() throws SAXException {
attributeName = AttributeName.nameByBuffer(strBuf, 0, strBufLen
// [NOCPP[
, namePolicy != XmlViolationPolicy.ALLOW
// ]NOCPP]
, interner);
attributeName = AttributeName.nameByBuffer(strBuf, 0, strBufLen, interner);
if (attributeName == null) {
// [NOCPP[
attributeName = AttributeName.createAttributeName(
Portability.newLocalNameFromBuffer(strBuf, 0, strBufLen,
interner),
namePolicy != XmlViolationPolicy.ALLOW);
// ]NOCPP]
// CPPONLY: nonInternedAttributeName.setNameForNonInterned(Portability.newLocalNameFromBuffer(strBuf, 0, strBufLen, interner));
// CPPONLY: attributeName = nonInternedAttributeName;
}
clearStrBufAfterUse();
if (attributes == null) {
@ -1180,7 +1230,6 @@ public class Tokenizer implements Locator {
*/
if (attributes.contains(attributeName)) {
errDuplicateAttribute();
attributeName.release();
attributeName = null;
}
}
@ -1229,8 +1278,7 @@ public class Tokenizer implements Locator {
// [NOCPP[
}
// ]NOCPP]
attributeName = null; // attributeName has been adopted by the
// |attributes| object
attributeName = null;
} else {
clearStrBufAfterUse();
}
@ -1261,8 +1309,7 @@ public class Tokenizer implements Locator {
// ]NOCPP]
// CPPONLY: , attributeLine
);
attributeName = null; // attributeName has been adopted by the
// |attributes| object
attributeName = null;
} else {
// We have a duplicate attribute. Explicitly discard its value.
clearStrBufAfterUse();
@ -1563,6 +1610,7 @@ public class Tokenizer implements Locator {
*/
clearStrBufBeforeUse();
appendStrBuf((char) (c + 0x20));
containsHyphen = false;
/* then switch to the tag name state. */
state = transition(state, Tokenizer.TAG_NAME, reconsume, pos);
/*
@ -1583,6 +1631,7 @@ public class Tokenizer implements Locator {
*/
clearStrBufBeforeUse();
appendStrBuf(c);
containsHyphen = false;
/* then switch to the tag name state. */
state = transition(state, Tokenizer.TAG_NAME, reconsume, pos);
/*
@ -1726,6 +1775,8 @@ public class Tokenizer implements Locator {
* tag name.
*/
c += 0x20;
} else if (c == '-') {
containsHyphen = true;
}
/*
* Anything else Append the current input
@ -1733,6 +1784,7 @@ public class Tokenizer implements Locator {
* name.
*/
appendStrBuf(c);
containsHyphen = false;
/*
* Stay in the tag name state.
*/
@ -6650,14 +6702,12 @@ public class Tokenizer implements Locator {
Portability.releaseString(publicIdentifier);
publicIdentifier = null;
}
if (tagName != null) {
tagName.release();
tagName = null;
}
if (attributeName != null) {
attributeName.release();
attributeName = null;
}
tagName = null;
nonInternedTagName.setNameForNonInterned(null
// CPPONLY: , false
);
attributeName = null;
// CPPONLY: nonInternedAttributeName.setNameForNonInterned(null);
tokenHandler.endTokenization();
if (attributes != null) {
// [NOCPP[
@ -6734,14 +6784,9 @@ public class Tokenizer implements Locator {
endTag = false;
shouldSuspend = false;
initDoctypeFields();
if (tagName != null) {
tagName.release();
tagName = null;
}
if (attributeName != null) {
attributeName.release();
attributeName = null;
}
containsHyphen = false;
tagName = null;
attributeName = null;
if (newAttributesEachTime) {
if (attributes != null) {
Portability.delete(attributes);
@ -6801,23 +6846,35 @@ public class Tokenizer implements Locator {
publicIdentifier = Portability.newStringFromString(other.publicIdentifier);
}
if (tagName != null) {
tagName.release();
}
containsHyphen = other.containsHyphen;
if (other.tagName == null) {
tagName = null;
} else if (other.tagName.isInterned()) {
tagName = other.tagName;
} else {
tagName = other.tagName.cloneElementName(interner);
// In the C++ case, the atoms in the other tokenizer are from a
// different tokenizer-scoped atom table. Therefore, we have to
// obtain the correspoding atom from our own atom table.
nonInternedTagName.setNameForNonInterned(Portability.newLocalFromLocal(other.tagName.getName(), interner)
// CPPONLY: , other.tagName.isCustom()
);
tagName = nonInternedTagName;
}
if (attributeName != null) {
attributeName.release();
}
if (other.attributeName == null) {
attributeName = null;
} else {
attributeName = other.attributeName.cloneAttributeName(interner);
}
// [NOCPP[
attributeName = other.attributeName;
// ]NOCPP]
// CPPONLY: if (other.attributeName == null) {
// CPPONLY: attributeName = null;
// CPPONLY: } else if (other.attributeName.isInterned()) {
// CPPONLY: attributeName = other.attributeName;
// CPPONLY: } else {
// CPPONLY: // In the C++ case, the atoms in the other tokenizer are from a
// CPPONLY: // different tokenizer-scoped atom table. Therefore, we have to
// CPPONLY: // obtain the correspoding atom from our own atom table.
// CPPONLY: nonInternedAttributeName.setNameForNonInterned(Portability.newLocalFromLocal(other.attributeName.getLocal(AttributeName.HTML), interner));
// CPPONLY: attributeName = nonInternedAttributeName;
// CPPONLY: }
Portability.delete(attributes);
if (other.attributes == null) {
@ -7058,6 +7115,9 @@ public class Tokenizer implements Locator {
}
void destructor() {
Portability.delete(nonInternedTagName);
// CPPONLY: Portability.delete(nonInternedAttributeName);
nonInternedTagName = null;
// The translator will write refcount tracing stuff here
Portability.delete(attributes);
attributes = null;

View file

@ -478,6 +478,18 @@ public abstract class TreeBuilder<T> implements TokenHandler,
protected void fatal() throws SAXException {
}
// CPPONLY: @Inline private @Creator Object htmlCreator(@HtmlCreator Object htmlCreator) {
// CPPONLY: @Creator Object creator;
// CPPONLY: creator.html = htmlCreator;
// CPPONLY: return creator;
// CPPONLY: }
// CPPONLY:
// CPPONLY: @Inline private @Creator Object svgCreator(@SvgCreator Object svgCreator) {
// CPPONLY: @Creator Object creator;
// CPPONLY: creator.svg = svgCreator;
// CPPONLY: return creator;
// CPPONLY: }
// [NOCPP[
protected final void fatal(Exception e) throws SAXException {
@ -634,7 +646,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
// This is the SVG variant of the StackNode constructor.
StackNode<T> node = new StackNode<T>(elementName,
elementName.camelCaseName, elt
elementName.getCamelCaseName(), elt
// [NOCPP[
, errorHandler == null ? null
: new TaintableLocatorImpl(tokenizer)
@ -664,7 +676,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
// This is the MathML variant of the StackNode constructor.
StackNode<T> node = new StackNode<T>(elementName, elt,
elementName.name, false
elementName.getName(), false
// [NOCPP[
, errorHandler == null ? null
: new TaintableLocatorImpl(tokenizer)
@ -714,7 +726,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: if (tokenizer.isViewingXmlSource()) {
// CPPONLY: T elt = createElement("http://www.w3.org/2000/svg",
// CPPONLY: "svg",
// CPPONLY: tokenizer.emptyAttributes(), null);
// CPPONLY: tokenizer.emptyAttributes(), null,
// CPPONLY: svgCreator(NS_NewSVGSVGElement));
// CPPONLY: StackNode<T> node = new StackNode<T>(ElementName.SVG,
// CPPONLY: "svg",
// CPPONLY: elt);
@ -1665,7 +1678,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
needToDropLF = false;
starttagloop: for (;;) {
int group = elementName.getGroup();
@Local String name = elementName.name;
@Local String name = elementName.getName();
if (isInForeign()) {
StackNode<T> currentNode = stack[currentPtr];
@NsUri String currNs = currentNode.ns;
@ -1958,8 +1971,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
attributes.getValue(AttributeName.TYPE))) {
break intableloop;
}
appendVoidElementToCurrent(
name, attributes,
appendVoidInputToCurrent(
attributes,
formPointer);
selfClosing = false;
attributes = null; // CPP
@ -2224,7 +2237,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U:
case FONT:
reconstructTheActiveFormattingElements();
maybeForgetEarlierDuplicateFormattingElement(elementName.name, attributes);
maybeForgetEarlierDuplicateFormattingElement(elementName.getName(), attributes);
appendToCurrentNodeAndPushFormattingElementMayFoster(
elementName,
attributes);
@ -2321,90 +2334,79 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case INPUT:
reconstructTheActiveFormattingElements();
appendVoidElementToCurrentMayFoster(
name, attributes,
elementName, attributes,
formPointer);
selfClosing = false;
attributes = null; // CPP
break starttagloop;
case ISINDEX:
errIsindex();
if (formPointer != null && !isTemplateContents()) {
break starttagloop;
}
implicitlyCloseP();
HtmlAttributes formAttrs = new HtmlAttributes(0);
int actionIndex = attributes.getIndex(AttributeName.ACTION);
if (actionIndex > -1) {
formAttrs.addAttribute(
AttributeName.ACTION,
attributes.getValueNoBoundsCheck(actionIndex)
// [NOCPP[
, XmlViolationPolicy.ALLOW
// ]NOCPP]
// CPPONLY: , attributes.getLineNoBoundsCheck(actionIndex)
);
}
appendToCurrentNodeAndPushFormElementMayFoster(formAttrs);
appendVoidElementToCurrentMayFoster(
ElementName.HR,
HtmlAttributes.EMPTY_ATTRIBUTES);
appendToCurrentNodeAndPushElementMayFoster(
ElementName.LABEL,
HtmlAttributes.EMPTY_ATTRIBUTES);
int promptIndex = attributes.getIndex(AttributeName.PROMPT);
if (promptIndex > -1) {
@Auto char[] prompt = Portability.newCharArrayFromString(attributes.getValueNoBoundsCheck(promptIndex));
appendCharacters(stack[currentPtr].node,
prompt, 0, prompt.length);
} else {
appendIsindexPrompt(stack[currentPtr].node);
}
HtmlAttributes inputAttributes = new HtmlAttributes(
0);
inputAttributes.addAttribute(
AttributeName.NAME,
Portability.newStringFromLiteral("isindex")
// [NOCPP[
, XmlViolationPolicy.ALLOW
// ]NOCPP]
// CPPONLY: , tokenizer.getLineNumber()
);
for (int i = 0; i < attributes.getLength(); i++) {
AttributeName attributeQName = attributes.getAttributeNameNoBoundsCheck(i);
if (AttributeName.NAME == attributeQName
|| AttributeName.PROMPT == attributeQName) {
attributes.releaseValue(i);
} else if (AttributeName.ACTION != attributeQName) {
inputAttributes.addAttribute(
attributeQName,
attributes.getValueNoBoundsCheck(i)
// [NOCPP[
, XmlViolationPolicy.ALLOW
// ]NOCPP]
// CPPONLY: , attributes.getLineNoBoundsCheck(i)
);
}
}
attributes.clearWithoutReleasingContents();
appendVoidElementToCurrentMayFoster(
"input",
inputAttributes, formPointer);
pop(); // label
appendVoidElementToCurrentMayFoster(
ElementName.HR,
HtmlAttributes.EMPTY_ATTRIBUTES);
pop(); // form
if (!isTemplateContents()) {
formPointer = null;
}
selfClosing = false;
// Portability.delete(formAttrs);
// Portability.delete(inputAttributes);
// Don't delete attributes, they are deleted
// later
break starttagloop;
// CPPONLY:case ISINDEX:
// CPPONLY: errIsindex();
// CPPONLY: if (formPointer != null && !isTemplateContents()) {
// CPPONLY: break starttagloop;
// CPPONLY: }
// CPPONLY: implicitlyCloseP();
// CPPONLY: HtmlAttributes formAttrs = new HtmlAttributes(0);
// CPPONLY: int actionIndex = attributes.getIndex(AttributeName.ACTION);
// CPPONLY: if (actionIndex > -1) {
// CPPONLY: formAttrs.addAttribute(
// CPPONLY: AttributeName.ACTION,
// CPPONLY: attributes.getValueNoBoundsCheck(actionIndex),
// CPPONLY: attributes.getLineNoBoundsCheck(actionIndex)
// CPPONLY: );
// CPPONLY: }
// CPPONLY: appendToCurrentNodeAndPushFormElementMayFoster(formAttrs);
// CPPONLY: appendVoidElementToCurrentMayFoster(
// CPPONLY: ElementName.HR,
// CPPONLY: HtmlAttributes.EMPTY_ATTRIBUTES);
// CPPONLY: appendToCurrentNodeAndPushElementMayFoster(
// CPPONLY: ElementName.LABEL,
// CPPONLY: HtmlAttributes.EMPTY_ATTRIBUTES);
// CPPONLY: int promptIndex = attributes.getIndex(AttributeName.PROMPT);
// CPPONLY: if (promptIndex > -1) {
// CPPONLY: @Auto char[] prompt = Portability.newCharArrayFromString(attributes.getValueNoBoundsCheck(promptIndex));
// CPPONLY: appendCharacters(stack[currentPtr].node,
// CPPONLY: prompt, 0, prompt.length);
// CPPONLY: } else {
// CPPONLY: appendIsindexPrompt(stack[currentPtr].node);
// CPPONLY: }
// CPPONLY: HtmlAttributes inputAttributes = new HtmlAttributes(
// CPPONLY: 0);
// CPPONLY: inputAttributes.addAttribute(
// CPPONLY: AttributeName.NAME,
// CPPONLY: Portability.newStringFromLiteral("isindex"),
// CPPONLY: tokenizer.getLineNumber()
// CPPONLY: );
// CPPONLY: for (int i = 0; i < attributes.getLength(); i++) {
// CPPONLY: @Local String attributeQName = attributes.getLocalNameNoBoundsCheck(i);
// CPPONLY: if ("name" == attributeQName
// CPPONLY: || "prompt" == attributeQName) {
// CPPONLY: attributes.releaseValue(i);
// CPPONLY: } else if ("action" != attributeQName) {
// CPPONLY: inputAttributes.AddAttributeWithLocal(
// CPPONLY: attributeQName,
// CPPONLY: attributes.getValueNoBoundsCheck(i),
// CPPONLY: attributes.getLineNoBoundsCheck(i)
// CPPONLY: );
// CPPONLY: }
// CPPONLY: }
// CPPONLY: attributes.clearWithoutReleasingContents();
// CPPONLY: appendVoidElementToCurrentMayFoster(
// CPPONLY: ElementName.INPUT,
// CPPONLY: inputAttributes, formPointer);
// CPPONLY: pop(); // label
// CPPONLY: appendVoidElementToCurrentMayFoster(
// CPPONLY: ElementName.HR,
// CPPONLY: HtmlAttributes.EMPTY_ATTRIBUTES);
// CPPONLY: pop(); // form
// CPPONLY:
// CPPONLY: if (!isTemplateContents()) {
// CPPONLY: formPointer = null;
// CPPONLY: }
// CPPONLY:
// CPPONLY: selfClosing = false;
// CPPONLY: // Don't delete attributes, they are deleted
// CPPONLY: // later
// CPPONLY: break starttagloop;
case TEXTAREA:
appendToCurrentNodeAndPushElementMayFoster(
elementName,
@ -3376,7 +3378,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
needToDropLF = false;
int eltPos;
int group = elementName.getGroup();
@Local String name = elementName.name;
@Local String name = elementName.getName();
endtagloop: for (;;) {
if (isInForeign()) {
if (stack[currentPtr].name != name) {
@ -3837,7 +3839,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case INPUT:
case KEYGEN: // XXX??
case HR:
case ISINDEX:
// CPPONLY: case ISINDEX:
case IFRAME:
case NOEMBED: // XXX???
case NOFRAMES: // XXX??
@ -4809,9 +4811,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
assert node == listOfActiveFormattingElements[nodeListPos];
assert node == stack[nodePos];
T clone = createElement("http://www.w3.org/1999/xhtml",
node.name, node.attributes.cloneAttributes(null), commonAncestor.node);
node.name, node.attributes.cloneAttributes(null), commonAncestor.node
// CPPONLY: , htmlCreator(node.getHtmlCreator())
);
StackNode<T> newNode = new StackNode<T>(node.getFlags(), node.ns,
node.name, clone, node.popName, node.attributes
// CPPONLY: , node.getHtmlCreator()
// [NOCPP[
, node.getLocator()
// ]NOCPP]
@ -4838,11 +4843,14 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
T clone = createElement("http://www.w3.org/1999/xhtml",
formattingElt.name,
formattingElt.attributes.cloneAttributes(null), furthestBlock.node);
formattingElt.attributes.cloneAttributes(null), furthestBlock.node
// CPPONLY: , htmlCreator(formattingElt.getHtmlCreator())
);
StackNode<T> formattingClone = new StackNode<T>(
formattingElt.getFlags(), formattingElt.ns,
formattingElt.name, clone, formattingElt.popName,
formattingElt.attributes
// CPPONLY: , formattingElt.getHtmlCreator()
// [NOCPP[
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
// ]NOCPP]
@ -5022,16 +5030,21 @@ public abstract class TreeBuilder<T> implements TokenHandler,
T clone;
if (currentNode.isFosterParenting()) {
clone = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", entry.name,
entry.attributes.cloneAttributes(null));
entry.attributes.cloneAttributes(null)
// CPPONLY: , htmlCreator(entry.getHtmlCreator())
);
} else {
clone = createElement("http://www.w3.org/1999/xhtml", entry.name,
entry.attributes.cloneAttributes(null), currentNode.node);
entry.attributes.cloneAttributes(null), currentNode.node
// CPPONLY: , htmlCreator(entry.getHtmlCreator())
);
appendElement(clone, currentNode.node);
}
StackNode<T> entryClone = new StackNode<T>(entry.getFlags(),
entry.ns, entry.name, clone, entry.popName,
entry.attributes
// CPPONLY: , entry.getHtmlCreator()
// [NOCPP[
, entry.getLocator()
// ]NOCPP]
@ -5062,23 +5075,33 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
private T createAndInsertFosterParentedElement(@NsUri String ns, @Local String name,
HtmlAttributes attributes) throws SAXException {
return createAndInsertFosterParentedElement(ns, name, attributes, null);
HtmlAttributes attributes
// CPPONLY: , @Creator Object creator
) throws SAXException {
return createAndInsertFosterParentedElement(ns, name, attributes, null
// CPPONLY: , creator
);
}
private T createAndInsertFosterParentedElement(@NsUri String ns, @Local String name,
HtmlAttributes attributes, T form) throws SAXException {
HtmlAttributes attributes, T form
// CPPONLY: , @Creator Object creator
) throws SAXException {
int tablePos = findLastOrRoot(TreeBuilder.TABLE);
int templatePos = findLastOrRoot(TreeBuilder.TEMPLATE);
if (templatePos >= tablePos) {
T child = createElement(ns, name, attributes, form, stack[templatePos].node);
T child = createElement(ns, name, attributes, form, stack[templatePos].node
// CPPONLY: , creator
);
appendElement(child, stack[templatePos].node);
return child;
}
StackNode<T> node = stack[tablePos];
return createAndInsertFosterParentedElement(ns, name, attributes, form, node.node, stack[tablePos - 1].node);
return createAndInsertFosterParentedElement(ns, name, attributes, form, node.node, stack[tablePos - 1].node
// CPPONLY: , creator
);
}
private boolean isInStack(StackNode<T> node) {
@ -5236,7 +5259,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
T currentNode = stack[currentPtr].node;
T elt = createElement("http://www.w3.org/1999/xhtml", "head", attributes, currentNode);
T elt = createElement("http://www.w3.org/1999/xhtml", "head", attributes, currentNode
/*
* head uses NS_NewHTMLSharedElement creator
*/
// CPPONLY: , htmlCreator(NS_NewHTMLSharedElement)
);
appendElement(elt, currentNode);
headPointer = elt;
StackNode<T> node = new StackNode<T>(ElementName.HEAD,
@ -5268,9 +5296,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", "form", attributes);
elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", "form", attributes
// CPPONLY: , htmlCreator(NS_NewHTMLFormElement)
);
} else {
elt = createElement("http://www.w3.org/1999/xhtml", "form", attributes, current.node);
elt = createElement("http://www.w3.org/1999/xhtml", "form", attributes, current.node
// CPPONLY: , htmlCreator(NS_NewHTMLFormElement)
);
appendElement(elt, current.node);
}
@ -5301,9 +5333,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.name, attributes);
elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
} else {
elt = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes, current.node);
elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, current.node
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
appendElement(elt, current.node);
}
StackNode<T> node = new StackNode<T>(elementName, elt, clone
@ -5324,7 +5360,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// ]NOCPP]
// This method can't be called for custom elements
T currentNode = stack[currentPtr].node;
T elt = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes, currentNode);
T elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(), attributes, currentNode
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
appendElement(elt, currentNode);
if (ElementName.TEMPLATE == elementName) {
elt = getDocumentFragmentForTemplate(elt);
@ -5340,10 +5378,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private void appendToCurrentNodeAndPushElementMayFoster(ElementName elementName,
HtmlAttributes attributes)
throws SAXException {
@Local String popName = elementName.name;
@Local String popName = elementName.getName();
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
if (elementName.isCustom()) {
if (!elementName.isInterned()) {
popName = checkPopName(popName);
}
// ]NOCPP]
@ -5351,9 +5389,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", popName, attributes);
elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", popName, attributes
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
} else {
elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node);
elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
appendElement(elt, current.node);
}
StackNode<T> node = new StackNode<T>(elementName, elt, popName
@ -5367,10 +5409,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private void appendToCurrentNodeAndPushElementMayFosterMathML(
ElementName elementName, HtmlAttributes attributes)
throws SAXException {
@Local String popName = elementName.name;
@Local String popName = elementName.getName();
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/1998/Math/MathML");
if (elementName.isCustom()) {
if (!elementName.isInterned()) {
popName = checkPopName(popName);
}
// ]NOCPP]
@ -5385,9 +5427,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
elt = createAndInsertFosterParentedElement("http://www.w3.org/1998/Math/MathML", popName, attributes);
elt = createAndInsertFosterParentedElement("http://www.w3.org/1998/Math/MathML", popName, attributes
// CPPONLY: , htmlCreator(null)
);
} else {
elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node);
elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node
// CPPONLY: , htmlCreator(null)
);
appendElement(elt, current.node);
}
StackNode<T> node = new StackNode<T>(elementName, elt, popName,
@ -5423,10 +5469,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private void appendToCurrentNodeAndPushElementMayFosterSVG(
ElementName elementName, HtmlAttributes attributes)
throws SAXException {
@Local String popName = elementName.camelCaseName;
@Local String popName = elementName.getCamelCaseName();
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/2000/svg");
if (elementName.isCustom()) {
if (!elementName.isInterned()) {
popName = checkPopName(popName);
}
// ]NOCPP]
@ -5434,9 +5480,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
elt = createAndInsertFosterParentedElement("http://www.w3.org/2000/svg", popName, attributes);
elt = createAndInsertFosterParentedElement("http://www.w3.org/2000/svg", popName, attributes
// CPPONLY: , svgCreator(elementName.getSvgCreator())
);
} else {
elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node);
elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node
// CPPONLY: , svgCreator(elementName.getSvgCreator())
);
appendElement(elt, current.node);
}
StackNode<T> node = new StackNode<T>(elementName, popName, elt
@ -5459,11 +5509,15 @@ public abstract class TreeBuilder<T> implements TokenHandler,
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.name,
attributes, formOwner);
elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.getName(),
attributes, formOwner
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
} else {
elt = createElement("http://www.w3.org/1999/xhtml", elementName.name,
attributes, formOwner, current.node);
elt = createElement("http://www.w3.org/1999/xhtml", elementName.getName(),
attributes, formOwner, current.node
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
appendElement(elt, current.node);
}
StackNode<T> node = new StackNode<T>(elementName, elt
@ -5475,7 +5529,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
private void appendVoidElementToCurrentMayFoster(
@Local String name, HtmlAttributes attributes, T form) throws SAXException {
ElementName elementName, HtmlAttributes attributes, T form) throws SAXException {
@Local String name = elementName.getName();
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
@ -5486,10 +5541,14 @@ public abstract class TreeBuilder<T> implements TokenHandler,
if (current.isFosterParenting()) {
fatal();
elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", name,
attributes, formOwner);
attributes, formOwner
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
} else {
elt = createElement("http://www.w3.org/1999/xhtml", name,
attributes, formOwner, current.node);
attributes, formOwner, current.node
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/1999/xhtml", name, elt);
@ -5499,10 +5558,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private void appendVoidElementToCurrentMayFoster(
ElementName elementName, HtmlAttributes attributes)
throws SAXException {
@Local String popName = elementName.name;
@Local String popName = elementName.getName();
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
if (elementName.isCustom()) {
if (!elementName.isInterned()) {
popName = checkPopName(popName);
}
// ]NOCPP]
@ -5510,9 +5569,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", popName, attributes);
elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", popName, attributes
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
} else {
elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node);
elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node
// CPPONLY: , htmlCreator(elementName.getHtmlCreator())
);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/1999/xhtml", popName, elt);
@ -5522,10 +5585,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private void appendVoidElementToCurrentMayFosterSVG(
ElementName elementName, HtmlAttributes attributes)
throws SAXException {
@Local String popName = elementName.camelCaseName;
@Local String popName = elementName.getCamelCaseName();
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/2000/svg");
if (elementName.isCustom()) {
if (!elementName.isInterned()) {
popName = checkPopName(popName);
}
// ]NOCPP]
@ -5533,9 +5596,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
elt = createAndInsertFosterParentedElement("http://www.w3.org/2000/svg", popName, attributes);
elt = createAndInsertFosterParentedElement("http://www.w3.org/2000/svg", popName, attributes
// CPPONLY: , svgCreator(elementName.getSvgCreator())
);
} else {
elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node);
elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node
// CPPONLY: , svgCreator(elementName.getSvgCreator())
);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/2000/svg", popName, elt);
@ -5545,10 +5612,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private void appendVoidElementToCurrentMayFosterMathML(
ElementName elementName, HtmlAttributes attributes)
throws SAXException {
@Local String popName = elementName.name;
@Local String popName = elementName.getName();
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/1998/Math/MathML");
if (elementName.isCustom()) {
if (!elementName.isInterned()) {
popName = checkPopName(popName);
}
// ]NOCPP]
@ -5556,27 +5623,32 @@ public abstract class TreeBuilder<T> implements TokenHandler,
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
elt = createAndInsertFosterParentedElement("http://www.w3.org/1998/Math/MathML", popName, attributes);
elt = createAndInsertFosterParentedElement("http://www.w3.org/1998/Math/MathML", popName, attributes
// CPPONLY: , htmlCreator(null)
);
} else {
elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node);
elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node
// CPPONLY: , htmlCreator(null)
);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/1998/Math/MathML", popName, elt);
elementPopped("http://www.w3.org/1998/Math/MathML", popName, elt);
}
private void appendVoidElementToCurrent(
@Local String name, HtmlAttributes attributes, T form) throws SAXException {
private void appendVoidInputToCurrent(HtmlAttributes attributes, T form) throws SAXException {
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
// Can't be called for custom elements
T currentNode = stack[currentPtr].node;
T elt = createElement("http://www.w3.org/1999/xhtml", name, attributes,
form == null || fragment || isTemplateContents() ? null : form, currentNode);
T elt = createElement("http://www.w3.org/1999/xhtml", "input", attributes,
form == null || fragment || isTemplateContents() ? null : form, currentNode
// CPPONLY: , htmlCreator(NS_NewHTMLInputElement)
);
appendElement(elt, currentNode);
elementPushed("http://www.w3.org/1999/xhtml", name, elt);
elementPopped("http://www.w3.org/1999/xhtml", name, elt);
elementPushed("http://www.w3.org/1999/xhtml", "input", elt);
elementPopped("http://www.w3.org/1999/xhtml", "input", elt);
}
private void appendVoidFormToCurrent(HtmlAttributes attributes) throws SAXException {
@ -5585,7 +5657,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// ]NOCPP]
T currentNode = stack[currentPtr].node;
T elt = createElement("http://www.w3.org/1999/xhtml", "form",
attributes, currentNode);
attributes, currentNode
// CPPONLY: , htmlCreator(NS_NewHTMLFormElement)
);
formPointer = elt;
// ownership transferred to form pointer
appendElement(elt, currentNode);
@ -5637,11 +5711,17 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
protected abstract T createElement(@NsUri String ns, @Local String name,
HtmlAttributes attributes, T intendedParent) throws SAXException;
HtmlAttributes attributes, T intendedParent
// CPPONLY: , @Creator Object creator
) throws SAXException;
protected T createElement(@NsUri String ns, @Local String name,
HtmlAttributes attributes, T form, T intendedParent) throws SAXException {
return createElement("http://www.w3.org/1999/xhtml", name, attributes, intendedParent);
HtmlAttributes attributes, T form, T intendedParent
// CPPONLY: , @Creator Object creator
) throws SAXException {
return createElement("http://www.w3.org/1999/xhtml", name, attributes, intendedParent
// CPPONLY: , creator
);
}
protected abstract T createHtmlElementSetAsRoot(HtmlAttributes attributes)
@ -5670,7 +5750,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// ]NOCPP]
protected T createAndInsertFosterParentedElement(@NsUri String ns, @Local String name,
HtmlAttributes attributes, T form, T table, T stackParent) throws SAXException {
HtmlAttributes attributes, T form, T table, T stackParent
// CPPONLY: , @Creator Object creator
) throws SAXException {
return createAndInsertFosterParentedElement(ns, name, attributes, table, stackParent);
};
@ -5681,7 +5763,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
protected abstract void appendCharacters(T parent, @NoLength char[] buf,
int start, int length) throws SAXException;
protected abstract void appendIsindexPrompt(T parent) throws SAXException;
// CPPONLY: protected abstract void appendIsindexPrompt(T parent) throws SAXException;
protected abstract void appendComment(T parent, @NoLength char[] buf,
int start, int length) throws SAXException;
@ -5952,6 +6034,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
StackNode<T> newNode = new StackNode<T>(node.getFlags(), node.ns,
node.name, node.node, node.popName,
node.attributes.cloneAttributes(null)
// CPPONLY: , node.getHtmlCreator()
// [NOCPP[
, node.getLocator()
// ]NOCPP]
@ -5969,6 +6052,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
StackNode<T> newNode = new StackNode<T>(node.getFlags(), node.ns,
node.name, node.node, node.popName,
null
// CPPONLY: , node.getHtmlCreator()
// [NOCPP[
, node.getLocator()
// ]NOCPP]
@ -6074,6 +6158,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
Portability.newLocalFromLocal(node.name, interner), node.node,
Portability.newLocalFromLocal(node.popName, interner),
node.attributes.cloneAttributes(null)
// CPPONLY: , node.getHtmlCreator()
// [NOCPP[
, node.getLocator()
// ]NOCPP]
@ -6091,6 +6176,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
Portability.newLocalFromLocal(node.name, interner), node.node,
Portability.newLocalFromLocal(node.popName, interner),
null
// CPPONLY: , node.getHtmlCreator()
// [NOCPP[
, node.getLocator()
// ]NOCPP]
@ -6377,9 +6463,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
err("Saw a start tag \u201Cimage\u201D.");
}
private void errIsindex() throws SAXException {
err("\u201Cisindex\u201D seen.");
}
// CPPONLY: private void errIsindex() throws SAXException {
// CPPONLY: err("\u201Cisindex\u201D seen.");
// CPPONLY: }
private void errFooSeenWhenFooOpen(@Local String name) throws SAXException {
if (errorHandler == null) {

View file

@ -23,26 +23,24 @@
package nu.validator.htmlparser.sax;
import nu.validator.htmlparser.impl.HtmlAttributes;
import nu.validator.htmlparser.impl.TreeBuilder;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.ext.LexicalHandler;
class SAXStreamer extends TreeBuilder<Attributes>{
import nu.validator.htmlparser.impl.HtmlAttributes;
import nu.validator.htmlparser.impl.TreeBuilder;
private static final char[] ISINDEX_PROMPT = "This is a searchable index. Enter search keywords: ".toCharArray();
class SAXStreamer extends TreeBuilder<Attributes>{
private ContentHandler contentHandler = null;
private LexicalHandler lexicalHandler = null;
SAXStreamer() {
super();
}
@Override
protected void addAttributesToElement(Attributes element, HtmlAttributes attributes) throws SAXException {
Attributes existingAttrs = element;
@ -59,14 +57,6 @@ class SAXStreamer extends TreeBuilder<Attributes>{
contentHandler.characters(buf, start, length);
}
/**
* @see nu.validator.htmlparser.impl.TreeBuilder#appendIsindexPrompt(java.lang.Object)
*/
@Override protected void appendIsindexPrompt(Attributes parent)
throws SAXException {
contentHandler.characters(ISINDEX_PROMPT, 0, ISINDEX_PROMPT.length);
}
@Override
protected void appendChildrenToNewParent(Attributes oldParent, Attributes newParent) throws SAXException {
fatal();

View file

@ -23,6 +23,8 @@
package nu.validator.htmlparser.sax;
import org.xml.sax.SAXException;
import nu.validator.htmlparser.impl.HtmlAttributes;
import nu.validator.htmlparser.impl.TreeBuilder;
import nu.validator.saxtree.Characters;
@ -34,12 +36,8 @@ import nu.validator.saxtree.Element;
import nu.validator.saxtree.Node;
import nu.validator.saxtree.ParentNode;
import org.xml.sax.SAXException;
class SAXTreeBuilder extends TreeBuilder<Element> {
private static final char[] ISINDEX_PROMPT = "This is a searchable index. Enter search keywords: ".toCharArray();
private Document document;
private Node cachedTable = null;
@ -65,14 +63,6 @@ class SAXTreeBuilder extends TreeBuilder<Element> {
parent.appendChild(new Characters(tokenizer, buf, start, length));
}
/**
* @see nu.validator.htmlparser.impl.TreeBuilder#appendIsindexPrompt(java.lang.Object)
*/
@Override protected void appendIsindexPrompt(Element parent)
throws SAXException {
parent.appendChild(new Characters(tokenizer, ISINDEX_PROMPT, 0, ISINDEX_PROMPT.length));
}
@Override
protected boolean hasChildren(Element element) {
return element.getFirstChild() != null;

View file

@ -23,11 +23,6 @@
package nu.validator.htmlparser.test;
import nu.validator.htmlparser.common.TokenHandler;
import nu.validator.htmlparser.impl.ElementName;
import nu.validator.htmlparser.impl.HtmlAttributes;
import nu.validator.htmlparser.impl.Tokenizer;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@ -38,6 +33,11 @@ import com.sdicons.json.model.JSONNull;
import com.sdicons.json.model.JSONObject;
import com.sdicons.json.model.JSONString;
import nu.validator.htmlparser.common.TokenHandler;
import nu.validator.htmlparser.impl.ElementName;
import nu.validator.htmlparser.impl.HtmlAttributes;
import nu.validator.htmlparser.impl.Tokenizer;
public class JSONArrayTokenHandler implements TokenHandler, ErrorHandler {
private static final JSONString DOCTYPE = new JSONString("DOCTYPE");
@ -102,7 +102,7 @@ public class JSONArrayTokenHandler implements TokenHandler, ErrorHandler {
}
public void endTag(ElementName eltName) throws SAXException {
String name = eltName.name;
String name = eltName.getName();
flushCharacters();
JSONArray token = new JSONArray();
token.getValue().add(END_TAG);
@ -123,7 +123,7 @@ public class JSONArrayTokenHandler implements TokenHandler, ErrorHandler {
public void startTag(ElementName eltName, HtmlAttributes attributes,
boolean selfClosing) throws SAXException {
String name = eltName.name;
String name = eltName.getName();
flushCharacters();
JSONArray token = new JSONArray();
token.getValue().add(START_TAG);

View file

@ -29,6 +29,11 @@ import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import nu.validator.htmlparser.common.TokenHandler;
import nu.validator.htmlparser.impl.ElementName;
import nu.validator.htmlparser.impl.ErrorReportingTokenizer;
@ -36,11 +41,6 @@ import nu.validator.htmlparser.impl.HtmlAttributes;
import nu.validator.htmlparser.impl.Tokenizer;
import nu.validator.htmlparser.io.Driver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class TokenPrinter implements TokenHandler, ErrorHandler {
private final Writer writer;
@ -94,7 +94,7 @@ public class TokenPrinter implements TokenHandler, ErrorHandler {
public void endTag(ElementName eltName) throws SAXException {
try {
writer.write(')');
writer.write(eltName.name);
writer.write(eltName.getName());
writer.write('\n');
} catch (IOException e) {
throw new SAXException(e);
@ -117,7 +117,7 @@ public class TokenPrinter implements TokenHandler, ErrorHandler {
throws SAXException {
try {
writer.write('(');
writer.write(eltName.name);
writer.write(eltName.getName());
writer.write('\n');
for (int i = 0; i < attributes.getLength(); i++) {
writer.write('A');

View file

@ -72,6 +72,10 @@ public class AnnotationHelperVisitor<T> extends VoidVisitorAdapter<T> {
return hasAnnotation("NoLength");
}
protected boolean unsigned() {
return hasAnnotation("Unsigned");
}
protected boolean auto() {
return hasAnnotation("Auto");
}
@ -88,6 +92,18 @@ public class AnnotationHelperVisitor<T> extends VoidVisitorAdapter<T> {
return hasAnnotation("CharacterName");
}
protected boolean creator() {
return hasAnnotation("Creator");
}
protected boolean htmlCreator() {
return hasAnnotation("HtmlCreator");
}
protected boolean svgCreator() {
return hasAnnotation("SvgCreator");
}
private boolean hasAnnotation(String anno) {
if (currentAnnotations == null) {
return false;

View file

@ -117,7 +117,8 @@ public class CppTypes {
"nsHtml5String", "nsNameSpaceManager", "nsIContent", "nsTraceRefcnt",
"jArray", "nsHtml5ArrayCopy", "nsAHtml5TreeBuilderState",
"nsHtml5Atoms", "nsHtml5ByteReadable", "nsIUnicodeDecoder",
"nsHtml5Macros", "nsIContentHandle" };
"nsHtml5Macros", "nsIContentHandle", "nsHtml5Portability",
"nsHtml5ContentCreatorFunction"};
private static final String[] OTHER_DECLATIONS = {};
@ -192,6 +193,10 @@ public class CppTypes {
return "int32_t";
}
public String unsignedIntType() {
return "uint32_t";
}
public String stringType() {
return "nsHtml5String";
}
@ -228,6 +233,18 @@ public class CppTypes {
return "nsIContentHandle*";
}
public String htmlCreatorType() {
return "mozilla::dom::HTMLContentCreatorFunction";
}
public String svgCreatorType() {
return "mozilla::dom::SVGContentCreatorFunction";
}
public String creatorType() {
return "nsHtml5ContentCreatorFunction";
}
public String xhtmlNamespaceLiteral() {
return "kNameSpaceID_XHTML";
}

View file

@ -331,13 +331,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
} else if ("errorHandler".equals(n.getName())) {
printer.print(cppTypes.errorHandler());
} else {
String prefixedName = javaClassName + "." + n.getName();
String constant = symbolTable.cppDefinesByJavaNames.get(prefixedName);
if (constant != null) {
printer.print(constant);
} else {
printer.print(n.getName());
}
printer.print(n.getName());
}
}
@ -448,14 +442,6 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
printer.print("#include \"");
printer.print(className);
printer.printLn(".h\"");
if ("AttributeName".equals(javaClassName)
|| "ElementName".equals(javaClassName)) {
printer.print("#include \"");
printer.print(cppTypes.classPrefix());
printer.print("Releasable");
printer.print(javaClassName);
printer.printLn(".h\"");
}
printer.printLn();
}
@ -494,7 +480,15 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
name = cppTypes.stringType();
}
} else if ("T".equals(name) || "Object".equals(name)) {
name = cppTypes.nodeType();
if (htmlCreator()) {
name = cppTypes.htmlCreatorType();
} else if (svgCreator()) {
name = cppTypes.svgCreatorType();
} else if (creator()) {
name = cppTypes.creatorType();
} else {
name = cppTypes.nodeType();
}
} else if ("TokenHandler".equals(name)) {
name = cppTypes.classPrefix() + "TreeBuilder*";
} else if ("EncodingDeclarationHandler".equals(name)) {
@ -548,7 +542,11 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
case Float:
throw new IllegalStateException("Unsupported primitive.");
case Int:
printer.print(cppTypes.intType());
if (unsigned()) {
printer.print(cppTypes.unsignedIntType());
} else {
printer.print(cppTypes.intType());
}
break;
case Long:
throw new IllegalStateException("Unsupported primitive.");
@ -740,10 +738,14 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
printer.print(" ");
printer.print(className);
printer.print("::");
if ("AttributeName".equals(n.getType().toString())) {
printer.print("ATTR_");
} else if ("ElementName".equals(n.getType().toString())) {
printer.print("ELT_");
String clazzName = n.getType().toString();
String field = declarator.getId().toString();
if (symbolTable.isAttributeOrElementName(clazzName, field)) {
if ("AttributeName".equals(clazzName)) {
printer.print("ATTR_");
} else if ("ElementName".equals(clazzName)) {
printer.print("ELT_");
}
}
declarator.getId().accept(this, arg);
printer.print(" = ");
@ -1079,26 +1081,22 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
if ("DocumentMode".equals(scope.toString())) {
// printer.print(cppTypes.documentModeType());
// printer.print(".");
} else if ("creator".equals(scope.toString()) || "this.creator".equals(scope.toString())) {
scope.accept(this, arg);
printer.print(".");
} else {
scope.accept(this, arg);
printer.print("->");
}
} else {
String prefixedName = clazzName + "." + field;
String constant = symbolTable.cppDefinesByJavaNames.get(prefixedName);
if (constant != null) {
printer.print(constant);
return;
} else {
printer.print(cppTypes.classPrefix());
printer.print(clazzName);
printer.print("::");
if (symbolTable.isNotAnAttributeOrElementName(field)) {
if ("AttributeName".equals(clazzName)) {
printer.print("ATTR_");
} else if ("ElementName".equals(clazzName)) {
printer.print("ELT_");
}
printer.print(cppTypes.classPrefix());
printer.print(clazzName);
printer.print("::");
if (symbolTable.isAttributeOrElementName(clazzName, field)) {
if ("AttributeName".equals(clazzName)) {
printer.print("ATTR_");
} else if ("ElementName".equals(clazzName)) {
printer.print("ELT_");
}
}
}
@ -1337,7 +1335,8 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
if (clazzName == null) {
scope.accept(this, arg);
if ("length".equals(n.getName())
|| "charAt".equals(n.getName())) {
|| "charAt".equals(n.getName())
|| "creator".equals(scope.toString())) {
printer.print(".");
} else {
printer.print("->");
@ -1383,19 +1382,12 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
suppressPointer = true;
printTypeArgs(n.getTypeArgs(), arg);
if ("createAttributeName".equals(currentMethod)
|| "elementNameByBuffer".equals(currentMethod)) {
printer.print(cppTypes.classPrefix());
printer.print("Releasable");
printer.print(n.getType().getName());
} else {
n.getType().accept(this, arg);
}
n.getType().accept(this, arg);
suppressPointer = false;
if ("AttributeName".equals(n.getType().getName())) {
List<Expression> args = n.getArgs();
while (args.size() > 3) {
while (args != null && args.size() > 3) {
args.remove(3);
}
}

View file

@ -37,7 +37,6 @@
package nu.validator.htmlparser.cpptranslate;
import java.util.LinkedList;
import java.util.List;
import japa.parser.ast.body.FieldDeclaration;
@ -45,12 +44,9 @@ import japa.parser.ast.body.MethodDeclaration;
import japa.parser.ast.body.ModifierSet;
import japa.parser.ast.body.Parameter;
import japa.parser.ast.body.VariableDeclarator;
import japa.parser.ast.expr.IntegerLiteralExpr;
import japa.parser.ast.expr.MethodCallExpr;
import japa.parser.ast.stmt.BlockStmt;
import japa.parser.ast.type.PrimitiveType;
import japa.parser.ast.type.ReferenceType;
import japa.parser.ast.type.Type;
public class HVisitor extends CppVisitor {
@ -60,8 +56,6 @@ public class HVisitor extends CppVisitor {
private Visibility previousVisibility = Visibility.NONE;
private List<String> defines = new LinkedList<String>();
/**
* @see nu.validator.htmlparser.cpptranslate.CppVisitor#printMethodNamespace()
*/
@ -145,10 +139,10 @@ public class HVisitor extends CppVisitor {
*/
@Override protected void endClassDeclaration() {
printModifiers(ModifierSet.PUBLIC | ModifierSet.STATIC);
printer.printLn("void initializeStatics();");
printer.printLn("void initializeStatics();");
printModifiers(ModifierSet.PUBLIC | ModifierSet.STATIC);
printer.printLn("void releaseStatics();");
printer.printLn("void releaseStatics();");
printer.unindent();
printer.unindent();
@ -161,13 +155,6 @@ public class HVisitor extends CppVisitor {
printer.printLn("};");
printer.printLn();
for (String define : defines) {
printer.printLn(define);
}
printer.printLn();
printer.printLn();
printer.printLn("#endif");
}
@ -226,18 +213,16 @@ public class HVisitor extends CppVisitor {
throw new IllegalStateException(
"More than one variable declared by one declarator.");
}
String name = javaClassName + "." + declarator.getId().getName();
String value = declarator.getInit().toString();
if ("Integer.MAX_VALUE".equals(value)) {
value = cppTypes.maxInteger();
}
String longName = definePrefix + declarator.getId().getName();
if (symbolTable.cppDefinesByJavaNames.containsKey(name)) {
throw new IllegalStateException(
"Duplicate #define constant local name: " + name);
}
symbolTable.cppDefinesByJavaNames.put(name, longName);
defines.add("#define " + longName + " " + value);
printModifiers(modifiers);
printer.print("const ");
n.getType().accept(this, arg);
printer.print(" ");
declarator.getId().accept(this, arg);
printer.print(" = ");
declarator.getInit().accept(this, arg);
printer.printLn(";");
printer.printLn();
symbolTable.addPrimitiveConstant(javaClassName, declarator.getId().toString());
} else {
if (n.getType() instanceof ReferenceType) {
ReferenceType rt = (ReferenceType) n.getType();

View file

@ -37,28 +37,26 @@
package nu.validator.htmlparser.cpptranslate;
import japa.parser.JavaParser;
import japa.parser.ParseException;
import japa.parser.ast.CompilationUnit;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import japa.parser.JavaParser;
import japa.parser.ParseException;
import japa.parser.ast.CompilationUnit;
public class Main {
static final String[] H_LIST = {
"AttributeName",
"ElementName",
"Tokenizer",
"TreeBuilder",
"MetaScanner",
"AttributeName",
"ElementName",
"HtmlAttributes",
"StackNode",
"UTF16Buffer",
"StateSnapshot",
@ -66,12 +64,11 @@ public class Main {
};
private static final String[] CPP_LIST = {
"AttributeName",
"ElementName",
"Tokenizer",
"TreeBuilder",
"MetaScanner",
"AttributeName",
"ElementName",
"HtmlAttributes",
"StackNode",
"UTF16Buffer",
"StateSnapshot",

View file

@ -38,11 +38,13 @@
package nu.validator.htmlparser.cpptranslate;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class SymbolTable {
public final Map<String, String> cppDefinesByJavaNames = new HashMap<String, String>();
private final Set<StringPair> primitiveConstants = new HashSet<StringPair>();
private final Map<StringPair, Type> fields = new HashMap<StringPair, Type>();
@ -51,17 +53,24 @@ public class SymbolTable {
/**
* This is a sad hack to work around the fact the there's no real symbol
* table yet.
*
* @param name
*
* @param field
* @return
*/
public boolean isNotAnAttributeOrElementName(String name) {
return !("ATTRIBUTE_HASHES".equals(name)
|| "ATTRIBUTE_NAMES".equals(name)
|| "ELEMENT_HASHES".equals(name)
|| "ELEMENT_NAMES".equals(name) || "ALL_NO_NS".equals(name));
public boolean isAttributeOrElementName(String klazz, String field) {
if (isPrimitiveConstant(klazz, field)) {
return false;
}
return !("ATTRIBUTE_HASHES".equals(field)
|| "ATTRIBUTE_NAMES".equals(field)
|| "ELEMENT_HASHES".equals(field)
|| "ELEMENT_NAMES".equals(field) || "ALL_NO_NS".equals(field));
}
public void addPrimitiveConstant(String klazz, String field) {
primitiveConstants.add(new StringPair(klazz, field));
}
public void putFieldType(String klazz, String field, Type type) {
fields.put(new StringPair(klazz, field), type);
}
@ -69,7 +78,11 @@ public class SymbolTable {
public void putMethodReturnType(String klazz, String method, Type type) {
methodReturns.put(new StringPair(klazz, method), type);
}
public boolean isPrimitiveConstant(String klazz, String field) {
return primitiveConstants.contains(new StringPair(klazz, field));
}
public Type getFieldType(String klazz, String field) {
return fields.get(new StringPair(klazz, field));
}

View file

@ -19,7 +19,10 @@ EXPORTS += [
'nsHtml5AtomList.h',
'nsHtml5Atoms.h',
'nsHtml5AtomTable.h',
'nsHtml5AttributeEntry.h',
'nsHtml5AttributeName.h',
'nsHtml5ByteReadable.h',
'nsHtml5ContentCreatorFunction.h',
'nsHtml5DependentUTF16Buffer.h',
'nsHtml5DocumentBuilder.h',
'nsHtml5DocumentMode.h',
@ -34,6 +37,7 @@ EXPORTS += [
'nsHtml5OwningUTF16Buffer.h',
'nsHtml5Parser.h',
'nsHtml5PlainTextUtils.h',
'nsHtml5Portability.h',
'nsHtml5RefPtr.h',
'nsHtml5Speculation.h',
'nsHtml5SpeculativeLoad.h',
@ -71,8 +75,6 @@ UNIFIED_SOURCES += [
'nsHtml5Parser.cpp',
'nsHtml5PlainTextUtils.cpp',
'nsHtml5Portability.cpp',
'nsHtml5ReleasableAttributeName.cpp',
'nsHtml5ReleasableElementName.cpp',
'nsHtml5Speculation.cpp',
'nsHtml5SpeculativeLoad.cpp',
'nsHtml5StackNode.cpp',

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,91 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsHtml5AttributeEntry_h
#define nsHtml5AttributeEntry_h
#include "nsHtml5AttributeName.h"
class nsHtml5AttributeEntry final
{
public:
nsHtml5AttributeEntry(nsHtml5AttributeName* aName,
nsHtml5String aValue,
int32_t aLine)
: mLine(aLine)
, mValue(aValue)
{
// Let's hope the compiler coalesces the following as appropriate.
mLocals[0] = aName->getLocal(0);
mLocals[1] = aName->getLocal(1);
mLocals[2] = aName->getLocal(2);
mPrefixes[0] = aName->getPrefix(0);
mPrefixes[1] = aName->getPrefix(1);
mPrefixes[2] = aName->getPrefix(2);
mUris[0] = aName->getUri(0);
mUris[1] = aName->getUri(1);
mUris[2] = aName->getUri(2);
}
// Isindex-only so doesn't need to deal with SVG and MathML
nsHtml5AttributeEntry(nsIAtom* aName, nsHtml5String aValue, int32_t aLine)
: mLine(aLine)
, mValue(aValue)
{
// Let's hope the compiler coalesces the following as appropriate.
mLocals[0] = aName;
mLocals[1] = aName;
mLocals[2] = aName;
mPrefixes[0] = nullptr;
mPrefixes[1] = nullptr;
mPrefixes[2] = nullptr;
mUris[0] = kNameSpaceID_None;
mUris[1] = kNameSpaceID_None;
mUris[2] = kNameSpaceID_None;
}
inline nsIAtom* GetLocal(int32_t aMode) { return mLocals[aMode]; }
inline nsIAtom* GetPrefix(int32_t aMode) { return mPrefixes[aMode]; }
inline int32_t GetUri(int32_t aMode) { return mUris[aMode]; }
inline nsHtml5String GetValue() { return mValue; }
inline int32_t GetLine() { return mLine; }
inline void ReleaseValue() { mValue.Release(); }
inline nsHtml5AttributeEntry Clone(nsHtml5AtomTable* aInterner)
{
// Copy the memory
nsHtml5AttributeEntry clone(*this);
// Increment refcount for value
clone.mValue = this->mValue.Clone();
if (aInterner) {
// Now if we have an interner, we'll need to rewrite non-static atoms.
// Only the local names may be non-static, in which case all three
// are the same.
nsIAtom* local = GetLocal(0);
if (!local->IsStaticAtom()) {
nsAutoString str;
local->ToString(str);
local = aInterner->GetAtom(str);
clone.mLocals[0] = local;
clone.mLocals[1] = local;
clone.mLocals[2] = local;
}
}
return clone;
}
private:
nsIAtom* mLocals[3];
nsIAtom* mPrefixes[3];
int32_t mUris[3];
int32_t mLine;
nsHtml5String mValue;
};
#endif // nsHtml5AttributeEntry_h

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsHtml5ContentCreatorFunction_h
#define nsHtml5ContentCreatorFunction_h
#include "nsGenericHTMLElement.h"
#include "mozilla/dom/SVGElementFactory.h"
union nsHtml5ContentCreatorFunction
{
mozilla::dom::HTMLContentCreatorFunction html;
mozilla::dom::SVGContentCreatorFunction svg;
};
#endif // nsHtml5ContentCreatorFunction_h

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2016 Mozilla Foundation
* Copyright (c) 2008-2017 Mozilla Foundation
* Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
*
@ -44,14 +44,15 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
#include "nsHtml5Portability.h"
#include "nsHtml5ContentCreatorFunction.h"
class nsHtml5StreamParser;
class nsHtml5AttributeName;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5MetaScanner;
class nsHtml5AttributeName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot;
class nsHtml5Portability;
@ -60,71 +61,155 @@ class nsHtml5Portability;
class nsHtml5ElementName
{
public:
static nsHtml5ElementName* ELT_NULL_ELEMENT_NAME;
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;
mozilla::dom::HTMLContentCreatorFunction htmlCreator;
mozilla::dom::SVGContentCreatorFunction svgCreator;
public:
int32_t flags;
inline nsIAtom* getName()
{
return name;
}
inline nsIAtom* getCamelCaseName()
{
return camelCaseName;
}
inline mozilla::dom::HTMLContentCreatorFunction getHtmlCreator()
{
return htmlCreator;
}
inline mozilla::dom::SVGContentCreatorFunction getSvgCreator()
{
return svgCreator;
}
inline int32_t getFlags()
{
return flags;
}
int32_t getGroup();
bool isCustom();
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 int32_t levelOrderBinarySearch(jArray<int32_t,int32_t> data, int32_t key)
{
int32_t n = data.length;
int32_t i = 0;
while (i < n) {
int32_t val = data[i];
if (val < key) {
i = 2 * i + 2;
} else if (val > key) {
i = 2 * i + 1;
} else {
return i;
}
}
return -1;
}
inline static nsHtml5ElementName* elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
{
uint32_t hash = nsHtml5ElementName::bufToHash(buf, length);
jArray<int32_t,int32_t> hashes;
hashes = nsHtml5ElementName::ELEMENT_HASHES;
int32_t index = levelOrderBinarySearch(hashes, 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:
static int32_t bufToHash(char16_t* buf, int32_t len);
nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, int32_t flags);
protected:
explicit nsHtml5ElementName(nsIAtom* name);
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;
uint32_t fourth = 0;
uint32_t fifth = 0;
if (length >= 4) {
second = buf[length - 4];
second <<= 4;
third = buf[length - 3];
third <<= 9;
fourth = buf[length - 2];
fourth <<= 14;
fifth = buf[length - 1];
fifth <<= 24;
} else if (length == 3) {
second = buf[1];
second <<= 4;
third = buf[2];
third <<= 9;
} else if (length == 2) {
second = buf[1];
second <<= 24;
}
return len + first + second + third + fourth + fifth;
}
nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, mozilla::dom::HTMLContentCreatorFunction htmlCreator, mozilla::dom::SVGContentCreatorFunction svgCreator, int32_t flags);
public:
virtual void release();
virtual ~nsHtml5ElementName();
virtual nsHtml5ElementName* cloneElementName(nsHtml5AtomTable* interner);
static nsHtml5ElementName* ELT_A;
static nsHtml5ElementName* ELT_B;
static nsHtml5ElementName* ELT_G;
static nsHtml5ElementName* ELT_I;
static nsHtml5ElementName* ELT_P;
static nsHtml5ElementName* ELT_Q;
static nsHtml5ElementName* ELT_S;
static nsHtml5ElementName* ELT_U;
static nsHtml5ElementName* ELT_BR;
static nsHtml5ElementName* ELT_CI;
static nsHtml5ElementName* ELT_CN;
static nsHtml5ElementName* ELT_DD;
static nsHtml5ElementName* ELT_DL;
static nsHtml5ElementName* ELT_DT;
static nsHtml5ElementName* ELT_EM;
static nsHtml5ElementName* ELT_EQ;
static nsHtml5ElementName* ELT_FN;
static nsHtml5ElementName* ELT_H1;
static nsHtml5ElementName* ELT_H2;
static nsHtml5ElementName* ELT_H3;
static nsHtml5ElementName* ELT_H4;
static nsHtml5ElementName* ELT_H5;
static nsHtml5ElementName* ELT_H6;
static nsHtml5ElementName* ELT_GT;
static nsHtml5ElementName* ELT_HR;
static nsHtml5ElementName* ELT_IN;
static nsHtml5ElementName* ELT_LI;
static nsHtml5ElementName* ELT_LN;
static nsHtml5ElementName* ELT_LT;
static nsHtml5ElementName* ELT_MI;
static nsHtml5ElementName* ELT_MN;
static nsHtml5ElementName* ELT_MO;
static nsHtml5ElementName* ELT_MS;
static nsHtml5ElementName* ELT_OL;
static nsHtml5ElementName* ELT_OR;
static nsHtml5ElementName* ELT_PI;
static nsHtml5ElementName* ELT_RB;
static nsHtml5ElementName* ELT_RP;
static nsHtml5ElementName* ELT_RT;
static nsHtml5ElementName* ELT_TD;
static nsHtml5ElementName* ELT_TH;
static nsHtml5ElementName* ELT_TR;
static nsHtml5ElementName* ELT_TT;
static nsHtml5ElementName* ELT_UL;
nsHtml5ElementName();
~nsHtml5ElementName();
inline void setNameForNonInterned(nsIAtom* name, bool custom)
{
this->name = name;
this->camelCaseName = name;
if (custom) {
this->htmlCreator = NS_NewCustomElement;
} else {
this->htmlCreator = NS_NewHTMLUnknownElement;
}
MOZ_ASSERT(this->flags == nsHtml5ElementName::NOT_INTERNED);
}
inline bool isCustom()
{
return this->htmlCreator == NS_NewCustomElement;
}
static nsHtml5ElementName* ELT_ISINDEX;
static nsHtml5ElementName* ELT_ANNOTATION_XML;
static nsHtml5ElementName* ELT_AND;
static nsHtml5ElementName* ELT_ARG;
static nsHtml5ElementName* ELT_ABS;
@ -157,6 +242,8 @@ class nsHtml5ElementName
static nsHtml5ElementName* ELT_NOT;
static nsHtml5ElementName* ELT_NAV;
static nsHtml5ElementName* ELT_PRE;
static nsHtml5ElementName* ELT_A;
static nsHtml5ElementName* ELT_B;
static nsHtml5ElementName* ELT_RTC;
static nsHtml5ElementName* ELT_REM;
static nsHtml5ElementName* ELT_SUB;
@ -170,315 +257,359 @@ class nsHtml5ElementName
static nsHtml5ElementName* ELT_TAN;
static nsHtml5ElementName* ELT_USE;
static nsHtml5ElementName* ELT_VAR;
static nsHtml5ElementName* ELT_G;
static nsHtml5ElementName* ELT_WBR;
static nsHtml5ElementName* ELT_XMP;
static nsHtml5ElementName* ELT_XOR;
static nsHtml5ElementName* ELT_I;
static nsHtml5ElementName* ELT_P;
static nsHtml5ElementName* ELT_Q;
static nsHtml5ElementName* ELT_S;
static nsHtml5ElementName* ELT_U;
static nsHtml5ElementName* ELT_H1;
static nsHtml5ElementName* ELT_H2;
static nsHtml5ElementName* ELT_H3;
static nsHtml5ElementName* ELT_H4;
static nsHtml5ElementName* ELT_H5;
static nsHtml5ElementName* ELT_H6;
static nsHtml5ElementName* ELT_AREA;
static nsHtml5ElementName* ELT_ABBR;
static nsHtml5ElementName* ELT_BASE;
static nsHtml5ElementName* ELT_BVAR;
static nsHtml5ElementName* ELT_BODY;
static nsHtml5ElementName* ELT_CARD;
static nsHtml5ElementName* ELT_CODE;
static nsHtml5ElementName* ELT_CITE;
static nsHtml5ElementName* ELT_CSCH;
static nsHtml5ElementName* ELT_COSH;
static nsHtml5ElementName* ELT_COTH;
static nsHtml5ElementName* ELT_CURL;
static nsHtml5ElementName* ELT_DESC;
static nsHtml5ElementName* ELT_DIFF;
static nsHtml5ElementName* ELT_DEFS;
static nsHtml5ElementName* ELT_FORM;
static nsHtml5ElementName* ELT_FONT;
static nsHtml5ElementName* ELT_GRAD;
static nsHtml5ElementName* ELT_HEAD;
static nsHtml5ElementName* ELT_HTML;
static nsHtml5ElementName* ELT_LINE;
static nsHtml5ElementName* ELT_LINK;
static nsHtml5ElementName* ELT_LIST;
static nsHtml5ElementName* ELT_DATA;
static nsHtml5ElementName* ELT_EULERGAMMA;
static nsHtml5ElementName* ELT_FEFUNCA;
static nsHtml5ElementName* ELT_LAMBDA;
static nsHtml5ElementName* ELT_METADATA;
static nsHtml5ElementName* ELT_META;
static nsHtml5ElementName* ELT_TEXTAREA;
static nsHtml5ElementName* ELT_FEFUNCB;
static nsHtml5ElementName* ELT_MSUB;
static nsHtml5ElementName* ELT_MODE;
static nsHtml5ElementName* ELT_MATH;
static nsHtml5ElementName* ELT_MARK;
static nsHtml5ElementName* ELT_MASK;
static nsHtml5ElementName* ELT_MEAN;
static nsHtml5ElementName* ELT_MAIN;
static nsHtml5ElementName* ELT_MSUP;
static nsHtml5ElementName* ELT_MENU;
static nsHtml5ElementName* ELT_MROW;
static nsHtml5ElementName* ELT_NONE;
static nsHtml5ElementName* ELT_NOBR;
static nsHtml5ElementName* ELT_NEST;
static nsHtml5ElementName* ELT_PATH;
static nsHtml5ElementName* ELT_PLUS;
static nsHtml5ElementName* ELT_RULE;
static nsHtml5ElementName* ELT_REAL;
static nsHtml5ElementName* ELT_RELN;
static nsHtml5ElementName* ELT_RECT;
static nsHtml5ElementName* ELT_ROOT;
static nsHtml5ElementName* ELT_RUBY;
static nsHtml5ElementName* ELT_SECH;
static nsHtml5ElementName* ELT_SINH;
static nsHtml5ElementName* ELT_SPAN;
static nsHtml5ElementName* ELT_SAMP;
static nsHtml5ElementName* ELT_STOP;
static nsHtml5ElementName* ELT_SDEV;
static nsHtml5ElementName* ELT_TIME;
static nsHtml5ElementName* ELT_TRUE;
static nsHtml5ElementName* ELT_TREF;
static nsHtml5ElementName* ELT_TANH;
static nsHtml5ElementName* ELT_TEXT;
static nsHtml5ElementName* ELT_VIEW;
static nsHtml5ElementName* ELT_ASIDE;
static nsHtml5ElementName* ELT_AUDIO;
static nsHtml5ElementName* ELT_APPLY;
static nsHtml5ElementName* ELT_EMBED;
static nsHtml5ElementName* ELT_FRAME;
static nsHtml5ElementName* ELT_FALSE;
static nsHtml5ElementName* ELT_FLOOR;
static nsHtml5ElementName* ELT_GLYPH;
static nsHtml5ElementName* ELT_HKERN;
static nsHtml5ElementName* ELT_IMAGE;
static nsHtml5ElementName* ELT_IDENT;
static nsHtml5ElementName* ELT_INPUT;
static nsHtml5ElementName* ELT_LABEL;
static nsHtml5ElementName* ELT_LIMIT;
static nsHtml5ElementName* ELT_MFRAC;
static nsHtml5ElementName* ELT_MPATH;
static nsHtml5ElementName* ELT_METER;
static nsHtml5ElementName* ELT_MOVER;
static nsHtml5ElementName* ELT_MINUS;
static nsHtml5ElementName* ELT_MROOT;
static nsHtml5ElementName* ELT_MSQRT;
static nsHtml5ElementName* ELT_MTEXT;
static nsHtml5ElementName* ELT_NOTIN;
static nsHtml5ElementName* ELT_PIECE;
static nsHtml5ElementName* ELT_PARAM;
static nsHtml5ElementName* ELT_POWER;
static nsHtml5ElementName* ELT_REALS;
static nsHtml5ElementName* ELT_STYLE;
static nsHtml5ElementName* ELT_SMALL;
static nsHtml5ElementName* ELT_THEAD;
static nsHtml5ElementName* ELT_TABLE;
static nsHtml5ElementName* ELT_TITLE;
static nsHtml5ElementName* ELT_TRACK;
static nsHtml5ElementName* ELT_TSPAN;
static nsHtml5ElementName* ELT_TIMES;
static nsHtml5ElementName* ELT_TFOOT;
static nsHtml5ElementName* ELT_TBODY;
static nsHtml5ElementName* ELT_UNION;
static nsHtml5ElementName* ELT_VKERN;
static nsHtml5ElementName* ELT_VIDEO;
static nsHtml5ElementName* ELT_RB;
static nsHtml5ElementName* ELT_ARCSEC;
static nsHtml5ElementName* ELT_ARCCSC;
static nsHtml5ElementName* ELT_ARCTAN;
static nsHtml5ElementName* ELT_ARCSIN;
static nsHtml5ElementName* ELT_ARCCOS;
static nsHtml5ElementName* ELT_APPLET;
static nsHtml5ElementName* ELT_ARCCOT;
static nsHtml5ElementName* ELT_APPROX;
static nsHtml5ElementName* ELT_BUTTON;
static nsHtml5ElementName* ELT_CIRCLE;
static nsHtml5ElementName* ELT_CENTER;
static nsHtml5ElementName* ELT_CURSOR;
static nsHtml5ElementName* ELT_CANVAS;
static nsHtml5ElementName* ELT_DIVIDE;
static nsHtml5ElementName* ELT_DEGREE;
static nsHtml5ElementName* ELT_DIALOG;
static nsHtml5ElementName* ELT_DOMAIN;
static nsHtml5ElementName* ELT_EXISTS;
static nsHtml5ElementName* ELT_FETILE;
static nsHtml5ElementName* ELT_FIGURE;
static nsHtml5ElementName* ELT_FORALL;
static nsHtml5ElementName* ELT_FILTER;
static nsHtml5ElementName* ELT_FOOTER;
static nsHtml5ElementName* ELT_HGROUP;
static nsHtml5ElementName* ELT_HEADER;
static nsHtml5ElementName* ELT_IFRAME;
static nsHtml5ElementName* ELT_KEYGEN;
static nsHtml5ElementName* ELT_LAMBDA;
static nsHtml5ElementName* ELT_DEFINITION_SRC;
static nsHtml5ElementName* ELT_DESC;
static nsHtml5ElementName* ELT_FONT_FACE_SRC;
static nsHtml5ElementName* ELT_MFRAC;
static nsHtml5ElementName* ELT_DD;
static nsHtml5ElementName* ELT_BGSOUND;
static nsHtml5ElementName* ELT_CARD;
static nsHtml5ElementName* ELT_DISCARD;
static nsHtml5ElementName* ELT_EMBED;
static nsHtml5ElementName* ELT_FEBLEND;
static nsHtml5ElementName* ELT_FEFLOOD;
static nsHtml5ElementName* ELT_GRAD;
static nsHtml5ElementName* ELT_HEAD;
static nsHtml5ElementName* ELT_LEGEND;
static nsHtml5ElementName* ELT_MSPACE;
static nsHtml5ElementName* ELT_MTABLE;
static nsHtml5ElementName* ELT_MSTYLE;
static nsHtml5ElementName* ELT_MGLYPH;
static nsHtml5ElementName* ELT_MEDIAN;
static nsHtml5ElementName* ELT_MUNDER;
static nsHtml5ElementName* ELT_MARKER;
static nsHtml5ElementName* ELT_MERROR;
static nsHtml5ElementName* ELT_MOMENT;
static nsHtml5ElementName* ELT_MATRIX;
static nsHtml5ElementName* ELT_OPTION;
static nsHtml5ElementName* ELT_OBJECT;
static nsHtml5ElementName* ELT_OUTPUT;
static nsHtml5ElementName* ELT_PRIMES;
static nsHtml5ElementName* ELT_SOURCE;
static nsHtml5ElementName* ELT_STRIKE;
static nsHtml5ElementName* ELT_STRONG;
static nsHtml5ElementName* ELT_SWITCH;
static nsHtml5ElementName* ELT_SYMBOL;
static nsHtml5ElementName* ELT_SELECT;
static nsHtml5ElementName* ELT_SUBSET;
static nsHtml5ElementName* ELT_SCRIPT;
static nsHtml5ElementName* ELT_TBREAK;
static nsHtml5ElementName* ELT_VECTOR;
static nsHtml5ElementName* ELT_MFENCED;
static nsHtml5ElementName* ELT_MPADDED;
static nsHtml5ElementName* ELT_NOEMBED;
static nsHtml5ElementName* ELT_TD;
static nsHtml5ElementName* ELT_THEAD;
static nsHtml5ElementName* ELT_ASIDE;
static nsHtml5ElementName* ELT_ARTICLE;
static nsHtml5ElementName* ELT_ANIMATE;
static nsHtml5ElementName* ELT_BASE;
static nsHtml5ElementName* ELT_BLOCKQUOTE;
static nsHtml5ElementName* ELT_CODE;
static nsHtml5ElementName* ELT_CIRCLE;
static nsHtml5ElementName* ELT_COLOR_PROFILE;
static nsHtml5ElementName* ELT_COMPOSE;
static nsHtml5ElementName* ELT_CONJUGATE;
static nsHtml5ElementName* ELT_CITE;
static nsHtml5ElementName* ELT_DIVERGENCE;
static nsHtml5ElementName* ELT_DIVIDE;
static nsHtml5ElementName* ELT_DEGREE;
static nsHtml5ElementName* ELT_DECLARE;
static nsHtml5ElementName* ELT_DATATEMPLATE;
static nsHtml5ElementName* ELT_EXPONENTIALE;
static nsHtml5ElementName* ELT_ELLIPSE;
static nsHtml5ElementName* ELT_FONT_FACE;
static nsHtml5ElementName* ELT_FETURBULENCE;
static nsHtml5ElementName* ELT_FEMERGENODE;
static nsHtml5ElementName* ELT_FEIMAGE;
static nsHtml5ElementName* ELT_FEMERGE;
static nsHtml5ElementName* ELT_FETILE;
static nsHtml5ElementName* ELT_FONT_FACE_NAME;
static nsHtml5ElementName* ELT_FRAME;
static nsHtml5ElementName* ELT_FIGURE;
static nsHtml5ElementName* ELT_FALSE;
static nsHtml5ElementName* ELT_FECOMPOSITE;
static nsHtml5ElementName* ELT_IMAGE;
static nsHtml5ElementName* ELT_IFRAME;
static nsHtml5ElementName* ELT_INVERSE;
static nsHtml5ElementName* ELT_LINE;
static nsHtml5ElementName* ELT_LOGBASE;
static nsHtml5ElementName* ELT_MSPACE;
static nsHtml5ElementName* ELT_MODE;
static nsHtml5ElementName* ELT_MARQUEE;
static nsHtml5ElementName* ELT_MTABLE;
static nsHtml5ElementName* ELT_MSTYLE;
static nsHtml5ElementName* ELT_MENCLOSE;
static nsHtml5ElementName* ELT_NONE;
static nsHtml5ElementName* ELT_OTHERWISE;
static nsHtml5ElementName* ELT_PIECE;
static nsHtml5ElementName* ELT_POLYLINE;
static nsHtml5ElementName* ELT_PICTURE;
static nsHtml5ElementName* ELT_PIECEWISE;
static nsHtml5ElementName* ELT_RULE;
static nsHtml5ElementName* ELT_SOURCE;
static nsHtml5ElementName* ELT_STRIKE;
static nsHtml5ElementName* ELT_STYLE;
static nsHtml5ElementName* ELT_TABLE;
static nsHtml5ElementName* ELT_TITLE;
static nsHtml5ElementName* ELT_TIME;
static nsHtml5ElementName* ELT_TRANSPOSE;
static nsHtml5ElementName* ELT_TEMPLATE;
static nsHtml5ElementName* ELT_TRUE;
static nsHtml5ElementName* ELT_VARIANCE;
static nsHtml5ElementName* ELT_ALTGLYPHDEF;
static nsHtml5ElementName* ELT_DIFF;
static nsHtml5ElementName* ELT_FACTOROF;
static nsHtml5ElementName* ELT_GLYPHREF;
static nsHtml5ElementName* ELT_PARTIALDIFF;
static nsHtml5ElementName* ELT_SETDIFF;
static nsHtml5ElementName* ELT_TREF;
static nsHtml5ElementName* ELT_CEILING;
static nsHtml5ElementName* ELT_DIALOG;
static nsHtml5ElementName* ELT_FEFUNCG;
static nsHtml5ElementName* ELT_FEDIFFUSELIGHTING;
static nsHtml5ElementName* ELT_FESPECULARLIGHTING;
static nsHtml5ElementName* ELT_LISTING;
static nsHtml5ElementName* ELT_STRONG;
static nsHtml5ElementName* ELT_ARCSECH;
static nsHtml5ElementName* ELT_ARCCSCH;
static nsHtml5ElementName* ELT_ARCTANH;
static nsHtml5ElementName* ELT_ARCSINH;
static nsHtml5ElementName* ELT_ALTGLYPH;
static nsHtml5ElementName* ELT_ARCCOSH;
static nsHtml5ElementName* ELT_ARCCOTH;
static nsHtml5ElementName* ELT_ACRONYM;
static nsHtml5ElementName* ELT_ADDRESS;
static nsHtml5ElementName* ELT_BGSOUND;
static nsHtml5ElementName* ELT_COMPOSE;
static nsHtml5ElementName* ELT_CEILING;
static nsHtml5ElementName* ELT_CSCH;
static nsHtml5ElementName* ELT_COSH;
static nsHtml5ElementName* ELT_CLIPPATH;
static nsHtml5ElementName* ELT_COTH;
static nsHtml5ElementName* ELT_GLYPH;
static nsHtml5ElementName* ELT_MGLYPH;
static nsHtml5ElementName* ELT_MISSING_GLYPH;
static nsHtml5ElementName* ELT_MATH;
static nsHtml5ElementName* ELT_MPATH;
static nsHtml5ElementName* ELT_PREFETCH;
static nsHtml5ElementName* ELT_PATH;
static nsHtml5ElementName* ELT_TH;
static nsHtml5ElementName* ELT_SECH;
static nsHtml5ElementName* ELT_SWITCH;
static nsHtml5ElementName* ELT_SINH;
static nsHtml5ElementName* ELT_TANH;
static nsHtml5ElementName* ELT_TEXTPATH;
static nsHtml5ElementName* ELT_CI;
static nsHtml5ElementName* ELT_FONT_FACE_URI;
static nsHtml5ElementName* ELT_LI;
static nsHtml5ElementName* ELT_IMAGINARYI;
static nsHtml5ElementName* ELT_MI;
static nsHtml5ElementName* ELT_PI;
static nsHtml5ElementName* ELT_LINK;
static nsHtml5ElementName* ELT_MARK;
static nsHtml5ElementName* ELT_MALIGNMARK;
static nsHtml5ElementName* ELT_MASK;
static nsHtml5ElementName* ELT_TBREAK;
static nsHtml5ElementName* ELT_TRACK;
static nsHtml5ElementName* ELT_DL;
static nsHtml5ElementName* ELT_CSYMBOL;
static nsHtml5ElementName* ELT_CURL;
static nsHtml5ElementName* ELT_FACTORIAL;
static nsHtml5ElementName* ELT_FORALL;
static nsHtml5ElementName* ELT_HTML;
static nsHtml5ElementName* ELT_INTERVAL;
static nsHtml5ElementName* ELT_OL;
static nsHtml5ElementName* ELT_LABEL;
static nsHtml5ElementName* ELT_UL;
static nsHtml5ElementName* ELT_REAL;
static nsHtml5ElementName* ELT_SMALL;
static nsHtml5ElementName* ELT_SYMBOL;
static nsHtml5ElementName* ELT_ALTGLYPHITEM;
static nsHtml5ElementName* ELT_ANIMATETRANSFORM;
static nsHtml5ElementName* ELT_ACRONYM;
static nsHtml5ElementName* ELT_EM;
static nsHtml5ElementName* ELT_FORM;
static nsHtml5ElementName* ELT_MENUITEM;
static nsHtml5ElementName* ELT_MPHANTOM;
static nsHtml5ElementName* ELT_PARAM;
static nsHtml5ElementName* ELT_CN;
static nsHtml5ElementName* ELT_ARCTAN;
static nsHtml5ElementName* ELT_ARCSIN;
static nsHtml5ElementName* ELT_ANIMATION;
static nsHtml5ElementName* ELT_ANNOTATION;
static nsHtml5ElementName* ELT_ANIMATEMOTION;
static nsHtml5ElementName* ELT_BUTTON;
static nsHtml5ElementName* ELT_FN;
static nsHtml5ElementName* ELT_CODOMAIN;
static nsHtml5ElementName* ELT_CAPTION;
static nsHtml5ElementName* ELT_DISCARD;
static nsHtml5ElementName* ELT_DECLARE;
static nsHtml5ElementName* ELT_DETAILS;
static nsHtml5ElementName* ELT_ELLIPSE;
static nsHtml5ElementName* ELT_FEFUNCA;
static nsHtml5ElementName* ELT_FEFUNCB;
static nsHtml5ElementName* ELT_FEBLEND;
static nsHtml5ElementName* ELT_FEFLOOD;
static nsHtml5ElementName* ELT_FEIMAGE;
static nsHtml5ElementName* ELT_FEMERGE;
static nsHtml5ElementName* ELT_FEFUNCG;
static nsHtml5ElementName* ELT_FEFUNCR;
static nsHtml5ElementName* ELT_HANDLER;
static nsHtml5ElementName* ELT_INVERSE;
static nsHtml5ElementName* ELT_IMPLIES;
static nsHtml5ElementName* ELT_ISINDEX;
static nsHtml5ElementName* ELT_LOGBASE;
static nsHtml5ElementName* ELT_LISTING;
static nsHtml5ElementName* ELT_MFENCED;
static nsHtml5ElementName* ELT_MPADDED;
static nsHtml5ElementName* ELT_MARQUEE;
static nsHtml5ElementName* ELT_CONDITION;
static nsHtml5ElementName* ELT_DOMAIN;
static nsHtml5ElementName* ELT_DOMAINOFAPPLICATION;
static nsHtml5ElementName* ELT_IN;
static nsHtml5ElementName* ELT_FIGCAPTION;
static nsHtml5ElementName* ELT_HKERN;
static nsHtml5ElementName* ELT_LN;
static nsHtml5ElementName* ELT_MN;
static nsHtml5ElementName* ELT_KEYGEN;
static nsHtml5ElementName* ELT_LAPLACIAN;
static nsHtml5ElementName* ELT_MEAN;
static nsHtml5ElementName* ELT_MEDIAN;
static nsHtml5ElementName* ELT_MAIN;
static nsHtml5ElementName* ELT_MACTION;
static nsHtml5ElementName* ELT_MSUBSUP;
static nsHtml5ElementName* ELT_NOEMBED;
static nsHtml5ElementName* ELT_PICTURE;
static nsHtml5ElementName* ELT_NOTIN;
static nsHtml5ElementName* ELT_OPTION;
static nsHtml5ElementName* ELT_POLYGON;
static nsHtml5ElementName* ELT_PATTERN;
static nsHtml5ElementName* ELT_PRODUCT;
static nsHtml5ElementName* ELT_SETDIFF;
static nsHtml5ElementName* ELT_RELN;
static nsHtml5ElementName* ELT_SPAN;
static nsHtml5ElementName* ELT_SECTION;
static nsHtml5ElementName* ELT_SUMMARY;
static nsHtml5ElementName* ELT_TSPAN;
static nsHtml5ElementName* ELT_UNION;
static nsHtml5ElementName* ELT_VKERN;
static nsHtml5ElementName* ELT_AUDIO;
static nsHtml5ElementName* ELT_MO;
static nsHtml5ElementName* ELT_TENDSTO;
static nsHtml5ElementName* ELT_UPLIMIT;
static nsHtml5ElementName* ELT_ALTGLYPH;
static nsHtml5ElementName* ELT_BASEFONT;
static nsHtml5ElementName* ELT_CLIPPATH;
static nsHtml5ElementName* ELT_CODOMAIN;
static nsHtml5ElementName* ELT_VIDEO;
static nsHtml5ElementName* ELT_COLGROUP;
static nsHtml5ElementName* ELT_FEDISPLACEMENTMAP;
static nsHtml5ElementName* ELT_HGROUP;
static nsHtml5ElementName* ELT_MALIGNGROUP;
static nsHtml5ElementName* ELT_MSUBSUP;
static nsHtml5ElementName* ELT_MSUP;
static nsHtml5ElementName* ELT_RP;
static nsHtml5ElementName* ELT_OPTGROUP;
static nsHtml5ElementName* ELT_SAMP;
static nsHtml5ElementName* ELT_STOP;
static nsHtml5ElementName* ELT_EQ;
static nsHtml5ElementName* ELT_BR;
static nsHtml5ElementName* ELT_ABBR;
static nsHtml5ElementName* ELT_ANIMATECOLOR;
static nsHtml5ElementName* ELT_BVAR;
static nsHtml5ElementName* ELT_CENTER;
static nsHtml5ElementName* ELT_CURSOR;
static nsHtml5ElementName* ELT_HR;
static nsHtml5ElementName* ELT_FEFUNCR;
static nsHtml5ElementName* ELT_FECOMPONENTTRANSFER;
static nsHtml5ElementName* ELT_FILTER;
static nsHtml5ElementName* ELT_FOOTER;
static nsHtml5ElementName* ELT_FLOOR;
static nsHtml5ElementName* ELT_FEGAUSSIANBLUR;
static nsHtml5ElementName* ELT_HEADER;
static nsHtml5ElementName* ELT_HANDLER;
static nsHtml5ElementName* ELT_OR;
static nsHtml5ElementName* ELT_LISTENER;
static nsHtml5ElementName* ELT_MUNDER;
static nsHtml5ElementName* ELT_MARKER;
static nsHtml5ElementName* ELT_METER;
static nsHtml5ElementName* ELT_MOVER;
static nsHtml5ElementName* ELT_MUNDEROVER;
static nsHtml5ElementName* ELT_MERROR;
static nsHtml5ElementName* ELT_MLABELEDTR;
static nsHtml5ElementName* ELT_NOBR;
static nsHtml5ElementName* ELT_NOTANUMBER;
static nsHtml5ElementName* ELT_POWER;
static nsHtml5ElementName* ELT_TR;
static nsHtml5ElementName* ELT_SOLIDCOLOR;
static nsHtml5ElementName* ELT_SELECTOR;
static nsHtml5ElementName* ELT_VECTOR;
static nsHtml5ElementName* ELT_ARCCOS;
static nsHtml5ElementName* ELT_ADDRESS;
static nsHtml5ElementName* ELT_CANVAS;
static nsHtml5ElementName* ELT_COMPLEXES;
static nsHtml5ElementName* ELT_DEFS;
static nsHtml5ElementName* ELT_DETAILS;
static nsHtml5ElementName* ELT_EXISTS;
static nsHtml5ElementName* ELT_IMPLIES;
static nsHtml5ElementName* ELT_INTEGERS;
static nsHtml5ElementName* ELT_MS;
static nsHtml5ElementName* ELT_MPRESCRIPTS;
static nsHtml5ElementName* ELT_MMULTISCRIPTS;
static nsHtml5ElementName* ELT_MINUS;
static nsHtml5ElementName* ELT_NOFRAMES;
static nsHtml5ElementName* ELT_NATURALNUMBERS;
static nsHtml5ElementName* ELT_PRIMES;
static nsHtml5ElementName* ELT_PROGRESS;
static nsHtml5ElementName* ELT_PLUS;
static nsHtml5ElementName* ELT_REALS;
static nsHtml5ElementName* ELT_RATIONALS;
static nsHtml5ElementName* ELT_SEMANTICS;
static nsHtml5ElementName* ELT_TIMES;
static nsHtml5ElementName* ELT_DT;
static nsHtml5ElementName* ELT_APPLET;
static nsHtml5ElementName* ELT_ARCCOT;
static nsHtml5ElementName* ELT_BASEFONT;
static nsHtml5ElementName* ELT_CARTESIANPRODUCT;
static nsHtml5ElementName* ELT_CONTENT;
static nsHtml5ElementName* ELT_GT;
static nsHtml5ElementName* ELT_DETERMINANT;
static nsHtml5ElementName* ELT_DATALIST;
static nsHtml5ElementName* ELT_EMPTYSET;
static nsHtml5ElementName* ELT_FACTOROF;
static nsHtml5ElementName* ELT_EQUIVALENT;
static nsHtml5ElementName* ELT_FONT_FACE_FORMAT;
static nsHtml5ElementName* ELT_FOREIGNOBJECT;
static nsHtml5ElementName* ELT_FIELDSET;
static nsHtml5ElementName* ELT_FRAMESET;
static nsHtml5ElementName* ELT_FEOFFSET;
static nsHtml5ElementName* ELT_GLYPHREF;
static nsHtml5ElementName* ELT_INTERVAL;
static nsHtml5ElementName* ELT_INTEGERS;
static nsHtml5ElementName* ELT_INFINITY;
static nsHtml5ElementName* ELT_LISTENER;
static nsHtml5ElementName* ELT_LOWLIMIT;
static nsHtml5ElementName* ELT_METADATA;
static nsHtml5ElementName* ELT_MENCLOSE;
static nsHtml5ElementName* ELT_MENUITEM;
static nsHtml5ElementName* ELT_MPHANTOM;
static nsHtml5ElementName* ELT_NOFRAMES;
static nsHtml5ElementName* ELT_NOSCRIPT;
static nsHtml5ElementName* ELT_OPTGROUP;
static nsHtml5ElementName* ELT_POLYLINE;
static nsHtml5ElementName* ELT_PREFETCH;
static nsHtml5ElementName* ELT_PROGRESS;
static nsHtml5ElementName* ELT_PRSUBSET;
static nsHtml5ElementName* ELT_QUOTIENT;
static nsHtml5ElementName* ELT_SELECTOR;
static nsHtml5ElementName* ELT_TEXTAREA;
static nsHtml5ElementName* ELT_TEMPLATE;
static nsHtml5ElementName* ELT_TEXTPATH;
static nsHtml5ElementName* ELT_VARIANCE;
static nsHtml5ElementName* ELT_ANIMATION;
static nsHtml5ElementName* ELT_CONJUGATE;
static nsHtml5ElementName* ELT_CONDITION;
static nsHtml5ElementName* ELT_COMPLEXES;
static nsHtml5ElementName* ELT_FONT_FACE;
static nsHtml5ElementName* ELT_FACTORIAL;
static nsHtml5ElementName* ELT_INTERSECT;
static nsHtml5ElementName* ELT_IMAGINARY;
static nsHtml5ElementName* ELT_LAPLACIAN;
static nsHtml5ElementName* ELT_MATRIXROW;
static nsHtml5ElementName* ELT_NOTSUBSET;
static nsHtml5ElementName* ELT_OTHERWISE;
static nsHtml5ElementName* ELT_PIECEWISE;
static nsHtml5ElementName* ELT_PLAINTEXT;
static nsHtml5ElementName* ELT_RATIONALS;
static nsHtml5ElementName* ELT_SEMANTICS;
static nsHtml5ElementName* ELT_TRANSPOSE;
static nsHtml5ElementName* ELT_ANNOTATION;
static nsHtml5ElementName* ELT_BLOCKQUOTE;
static nsHtml5ElementName* ELT_DIVERGENCE;
static nsHtml5ElementName* ELT_EULERGAMMA;
static nsHtml5ElementName* ELT_EQUIVALENT;
static nsHtml5ElementName* ELT_FIGCAPTION;
static nsHtml5ElementName* ELT_IMAGINARYI;
static nsHtml5ElementName* ELT_MALIGNMARK;
static nsHtml5ElementName* ELT_MUNDEROVER;
static nsHtml5ElementName* ELT_MLABELEDTR;
static nsHtml5ElementName* ELT_NOTANUMBER;
static nsHtml5ElementName* ELT_SOLIDCOLOR;
static nsHtml5ElementName* ELT_ALTGLYPHDEF;
static nsHtml5ElementName* ELT_DETERMINANT;
static nsHtml5ElementName* ELT_FEMERGENODE;
static nsHtml5ElementName* ELT_FECOMPOSITE;
static nsHtml5ElementName* ELT_FESPOTLIGHT;
static nsHtml5ElementName* ELT_MALIGNGROUP;
static nsHtml5ElementName* ELT_MPRESCRIPTS;
static nsHtml5ElementName* ELT_MOMENTABOUT;
static nsHtml5ElementName* ELT_NOTPRSUBSET;
static nsHtml5ElementName* ELT_PARTIALDIFF;
static nsHtml5ElementName* ELT_ALTGLYPHITEM;
static nsHtml5ElementName* ELT_ANIMATECOLOR;
static nsHtml5ElementName* ELT_DATATEMPLATE;
static nsHtml5ElementName* ELT_EXPONENTIALE;
static nsHtml5ElementName* ELT_FETURBULENCE;
static nsHtml5ElementName* ELT_FEPOINTLIGHT;
static nsHtml5ElementName* ELT_FEDROPSHADOW;
static nsHtml5ElementName* ELT_FEMORPHOLOGY;
static nsHtml5ElementName* ELT_OUTERPRODUCT;
static nsHtml5ElementName* ELT_ANIMATEMOTION;
static nsHtml5ElementName* ELT_COLOR_PROFILE;
static nsHtml5ElementName* ELT_FONT_FACE_SRC;
static nsHtml5ElementName* ELT_FONT_FACE_URI;
static nsHtml5ElementName* ELT_FOREIGNOBJECT;
static nsHtml5ElementName* ELT_FECOLORMATRIX;
static nsHtml5ElementName* ELT_MISSING_GLYPH;
static nsHtml5ElementName* ELT_MMULTISCRIPTS;
static nsHtml5ElementName* ELT_SCALARPRODUCT;
static nsHtml5ElementName* ELT_VECTORPRODUCT;
static nsHtml5ElementName* ELT_ANNOTATION_XML;
static nsHtml5ElementName* ELT_DEFINITION_SRC;
static nsHtml5ElementName* ELT_FONT_FACE_NAME;
static nsHtml5ElementName* ELT_FEGAUSSIANBLUR;
static nsHtml5ElementName* ELT_FEDISTANTLIGHT;
static nsHtml5ElementName* ELT_FONT;
static nsHtml5ElementName* ELT_LT;
static nsHtml5ElementName* ELT_INTERSECT;
static nsHtml5ElementName* ELT_IDENT;
static nsHtml5ElementName* ELT_INPUT;
static nsHtml5ElementName* ELT_LIMIT;
static nsHtml5ElementName* ELT_LOWLIMIT;
static nsHtml5ElementName* ELT_LINEARGRADIENT;
static nsHtml5ElementName* ELT_NATURALNUMBERS;
static nsHtml5ElementName* ELT_LIST;
static nsHtml5ElementName* ELT_MOMENT;
static nsHtml5ElementName* ELT_MROOT;
static nsHtml5ElementName* ELT_MSQRT;
static nsHtml5ElementName* ELT_MOMENTABOUT;
static nsHtml5ElementName* ELT_MTEXT;
static nsHtml5ElementName* ELT_NOTSUBSET;
static nsHtml5ElementName* ELT_NOTPRSUBSET;
static nsHtml5ElementName* ELT_NOSCRIPT;
static nsHtml5ElementName* ELT_NEST;
static nsHtml5ElementName* ELT_RT;
static nsHtml5ElementName* ELT_OBJECT;
static nsHtml5ElementName* ELT_OUTERPRODUCT;
static nsHtml5ElementName* ELT_OUTPUT;
static nsHtml5ElementName* ELT_PRODUCT;
static nsHtml5ElementName* ELT_PRSUBSET;
static nsHtml5ElementName* ELT_PLAINTEXT;
static nsHtml5ElementName* ELT_TT;
static nsHtml5ElementName* ELT_QUOTIENT;
static nsHtml5ElementName* ELT_RECT;
static nsHtml5ElementName* ELT_RADIALGRADIENT;
static nsHtml5ElementName* ELT_ANIMATETRANSFORM;
static nsHtml5ElementName* ELT_CARTESIANPRODUCT;
static nsHtml5ElementName* ELT_FONT_FACE_FORMAT;
static nsHtml5ElementName* ELT_ROOT;
static nsHtml5ElementName* ELT_SELECT;
static nsHtml5ElementName* ELT_SCALARPRODUCT;
static nsHtml5ElementName* ELT_SUBSET;
static nsHtml5ElementName* ELT_SCRIPT;
static nsHtml5ElementName* ELT_TFOOT;
static nsHtml5ElementName* ELT_TEXT;
static nsHtml5ElementName* ELT_UPLIMIT;
static nsHtml5ElementName* ELT_VECTORPRODUCT;
static nsHtml5ElementName* ELT_MENU;
static nsHtml5ElementName* ELT_SDEV;
static nsHtml5ElementName* ELT_FEDROPSHADOW;
static nsHtml5ElementName* ELT_MROW;
static nsHtml5ElementName* ELT_MATRIXROW;
static nsHtml5ElementName* ELT_SHADOW;
static nsHtml5ElementName* ELT_VIEW;
static nsHtml5ElementName* ELT_APPROX;
static nsHtml5ElementName* ELT_FECOLORMATRIX;
static nsHtml5ElementName* ELT_FECONVOLVEMATRIX;
static nsHtml5ElementName* ELT_FEDIFFUSELIGHTING;
static nsHtml5ElementName* ELT_FEDISPLACEMENTMAP;
static nsHtml5ElementName* ELT_FESPECULARLIGHTING;
static nsHtml5ElementName* ELT_DOMAINOFAPPLICATION;
static nsHtml5ElementName* ELT_FECOMPONENTTRANSFER;
static nsHtml5ElementName* ELT_MATRIX;
static nsHtml5ElementName* ELT_APPLY;
static nsHtml5ElementName* ELT_BODY;
static nsHtml5ElementName* ELT_FEMORPHOLOGY;
static nsHtml5ElementName* ELT_IMAGINARY;
static nsHtml5ElementName* ELT_INFINITY;
static nsHtml5ElementName* ELT_RUBY;
static nsHtml5ElementName* ELT_SUMMARY;
static nsHtml5ElementName* ELT_TBODY;
private:
static nsHtml5ElementName** ELEMENT_NAMES;
static staticJArray<int32_t,int32_t> ELEMENT_HASHES;
@ -487,16 +618,5 @@ class nsHtml5ElementName
static void releaseStatics();
};
#define NS_HTML5ELEMENT_NAME_GROUP_MASK 127
#define NS_HTML5ELEMENT_NAME_CUSTOM (1 << 30)
#define NS_HTML5ELEMENT_NAME_SPECIAL (1 << 29)
#define NS_HTML5ELEMENT_NAME_FOSTER_PARENTING (1 << 28)
#define NS_HTML5ELEMENT_NAME_SCOPING (1 << 27)
#define NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG (1 << 26)
#define NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML (1 << 25)
#define NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT (1 << 24)
#define NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG (1 << 23)
#endif

View file

@ -48,7 +48,7 @@ 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)
@ -79,13 +79,16 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle)
mOpQueue.AppendElement()->Init(STANDARDS_MODE);
nsIContent** root = CreateElement(nsHtml5Atoms::html, nullptr, nullptr);
// <html> uses NS_NewHTMLSharedElement creator
nsIContent** root =
CreateElement(nsHtml5Atoms::html, nullptr, nullptr, NS_NewHTMLSharedElement);
mOpQueue.AppendElement()->Init(eTreeOpAppendToDocument, root);
mStack.AppendElement(root);
Push(nsGkAtoms::head, nullptr);
// <head> uses NS_NewHTMLSharedElement creator
Push(nsGkAtoms::head, nullptr, NS_NewHTMLSharedElement);
Push(nsGkAtoms::title, nullptr);
Push(nsGkAtoms::title, nullptr, NS_NewHTMLTitleElement);
// XUL will add the "Source of: " prefix.
uint32_t length = aTitle.Length();
if (length > INT32_MAX) {
@ -94,7 +97,9 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle)
AppendCharacters(aTitle.BeginReading(), 0, (int32_t)length);
Pop(); // title
Push(nsGkAtoms::link, nsHtml5ViewSourceUtils::NewLinkAttributes());
Push(nsGkAtoms::link,
nsHtml5ViewSourceUtils::NewLinkAttributes(),
NS_NewHTMLLinkElement);
mOpQueue.AppendElement()->Init(eTreeOpUpdateStyleSheet, CurrentNode());
@ -102,12 +107,14 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle)
Pop(); // head
Push(nsGkAtoms::body, nsHtml5ViewSourceUtils::NewBodyAttributes());
Push(nsGkAtoms::body,
nsHtml5ViewSourceUtils::NewBodyAttributes(),
NS_NewHTMLBodyElement);
nsHtml5HtmlAttributes* preAttrs = new nsHtml5HtmlAttributes(0);
nsHtml5String preId = nsHtml5Portability::newStringFromLiteral("line1");
preAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, preId, -1);
Push(nsGkAtoms::pre, preAttrs);
Push(nsGkAtoms::pre, preAttrs, NS_NewHTMLPreElement);
StartCharacters();
@ -119,13 +126,13 @@ 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();
@ -134,26 +141,26 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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;
@ -162,12 +169,12 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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;
@ -176,14 +183,14 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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;
@ -192,14 +199,14 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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:
@ -207,13 +214,13 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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();
@ -223,11 +230,11 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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;
@ -236,22 +243,22 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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();
@ -261,15 +268,15 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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:
@ -279,30 +286,30 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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
@ -310,44 +317,44 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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;
@ -355,19 +362,19 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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;
@ -376,47 +383,47 @@ nsHtml5Highlighter::Transition(int32_t aState, bool aReconsume, int32_t aPos)
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;
@ -431,35 +438,35 @@ 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:
@ -492,7 +499,7 @@ void
nsHtml5Highlighter::StartSpan()
{
FlushChars();
Push(nsGkAtoms::span, nullptr);
Push(nsGkAtoms::span, nullptr, NS_NewHTMLSpanElement);
++mInlinesOpen;
}
@ -516,7 +523,7 @@ nsHtml5Highlighter::StartCharacters()
{
NS_PRECONDITION(!mInCharacters, "Already in characters!");
FlushChars();
Push(nsGkAtoms::span, nullptr);
Push(nsGkAtoms::span, nullptr, NS_NewHTMLSpanElement);
mCurrentRun = CurrentNode();
mInCharacters = true;
}
@ -537,7 +544,7 @@ void
nsHtml5Highlighter::StartA()
{
FlushChars();
Push(nsGkAtoms::a, nullptr);
Push(nsGkAtoms::a, nullptr, NS_NewHTMLAnchorElement);
AddClass(sAttributeValue);
++mInlinesOpen;
}
@ -579,7 +586,7 @@ nsHtml5Highlighter::FlushChars()
mCStart = i;
}
++mLineNumber;
Push(nsGkAtoms::span, nullptr);
Push(nsGkAtoms::span, nullptr, NS_NewHTMLSpanElement);
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->InitAddLineNumberId(CurrentNode(), mLineNumber);
@ -656,16 +663,20 @@ nsHtml5Highlighter::AllocateContentHandle()
nsIContent**
nsHtml5Highlighter::CreateElement(nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
nsIContent** aIntendedParent)
nsIContent** aIntendedParent,
mozilla::dom::HTMLContentCreatorFunction aCreator)
{
NS_PRECONDITION(aName, "Got null name.");
nsHtml5ContentCreatorFunction creator;
creator.html = aCreator;
nsIContent** content = AllocateContentHandle();
mOpQueue.AppendElement()->Init(kNameSpaceID_XHTML,
aName,
aAttributes,
content,
aIntendedParent,
true);
true,
creator);
return content;
}
@ -678,10 +689,13 @@ nsHtml5Highlighter::CurrentNode()
void
nsHtml5Highlighter::Push(nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes)
nsHtml5HtmlAttributes* aAttributes,
mozilla::dom::HTMLContentCreatorFunction aCreator)
{
NS_PRECONDITION(mStack.Length() >= 1, "Pushing without root.");
nsIContent** elt = CreateElement(aName, aAttributes, CurrentNode()); // Don't inline below!
nsIContent** elt = CreateElement(aName, aAttributes,
CurrentNode(),
aCreator); // Don't inline below!
mOpQueue.AppendElement()->Init(eTreeOpAppend, elt, CurrentNode());
mStack.AppendElement(elt);
}

View file

@ -227,11 +227,13 @@ class nsHtml5Highlighter
* @param aAttributes the attribute holder (ownership will be taken) or
* nullptr for no attributes
* @param aIntendedParent the intended parent node for the created element
* @param aCreator the content creator function
* @return the handle for the element that will be created
*/
nsIContent** CreateElement(nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
nsIContent** aIntendedParent);
nsIContent** aIntendedParent,
mozilla::dom::HTMLContentCreatorFunction aCreator);
/**
* Gets the handle for the current node. May be called only after the
@ -247,8 +249,11 @@ class nsHtml5Highlighter
* @param aName the name of the element
* @param aAttributes the attribute holder (ownership will be taken) or
* nullptr for no attributes
* @param aCreator the content creator function
*/
void Push(nsIAtom* aName, nsHtml5HtmlAttributes* aAttributes);
void Push(nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
mozilla::dom::HTMLContentCreatorFunction aCreator);
/**
* Pops the current node off the stack.

View file

@ -23,11 +23,6 @@
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit HtmlAttributes.java instead and regenerate.
*/
#define nsHtml5HtmlAttributes_cpp__
#include "nsIAtom.h"
@ -59,12 +54,8 @@
nsHtml5HtmlAttributes* nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES = nullptr;
nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(int32_t mode)
: mode(mode),
length(0),
names(jArray<nsHtml5AttributeName*,int32_t>::newJArray(8)),
values(jArray<nsHtml5String,int32_t>::newJArray(8)),
lines(jArray<int32_t,int32_t>::newJArray(8))
nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(int32_t aMode)
: mMode(aMode)
{
MOZ_COUNT_CTOR(nsHtml5HtmlAttributes);
}
@ -76,11 +67,13 @@ nsHtml5HtmlAttributes::~nsHtml5HtmlAttributes()
clear(0);
}
int32_t
nsHtml5HtmlAttributes::getIndex(nsHtml5AttributeName* name)
int32_t
nsHtml5HtmlAttributes::getIndex(nsHtml5AttributeName* aName)
{
for (int32_t i = 0; i < length; i++) {
if (names[i] == name) {
for (size_t i = 0; i < mStorage.Length(); i++) {
if (mStorage[i].GetLocal(nsHtml5AttributeName::HTML) ==
aName->getLocal(nsHtml5AttributeName::HTML)) {
// It's release asserted elsewhere that i can't be too large.
return i;
}
}
@ -88,9 +81,9 @@ nsHtml5HtmlAttributes::getIndex(nsHtml5AttributeName* name)
}
nsHtml5String
nsHtml5HtmlAttributes::getValue(nsHtml5AttributeName* name)
nsHtml5HtmlAttributes::getValue(nsHtml5AttributeName* aName)
{
int32_t index = getIndex(name);
int32_t index = getIndex(aName);
if (index == -1) {
return nullptr;
} else {
@ -101,106 +94,98 @@ nsHtml5HtmlAttributes::getValue(nsHtml5AttributeName* name)
int32_t
nsHtml5HtmlAttributes::getLength()
{
return length;
return mStorage.Length();
}
nsIAtom*
nsHtml5HtmlAttributes::getLocalNameNoBoundsCheck(int32_t index)
nsIAtom*
nsHtml5HtmlAttributes::getLocalNameNoBoundsCheck(int32_t aIndex)
{
MOZ_ASSERT(index < length && index >= 0, "Index out of bounds");
return names[index]->getLocal(mode);
MOZ_ASSERT(aIndex < int32_t(mStorage.Length()) && aIndex >= 0,
"Index out of bounds");
return mStorage[aIndex].GetLocal(mMode);
}
int32_t
nsHtml5HtmlAttributes::getURINoBoundsCheck(int32_t index)
int32_t
nsHtml5HtmlAttributes::getURINoBoundsCheck(int32_t aIndex)
{
MOZ_ASSERT(index < length && index >= 0, "Index out of bounds");
return names[index]->getUri(mode);
MOZ_ASSERT(aIndex < int32_t(mStorage.Length()) && aIndex >= 0,
"Index out of bounds");
return mStorage[aIndex].GetUri(mMode);
}
nsIAtom*
nsHtml5HtmlAttributes::getPrefixNoBoundsCheck(int32_t index)
nsIAtom*
nsHtml5HtmlAttributes::getPrefixNoBoundsCheck(int32_t aIndex)
{
MOZ_ASSERT(index < length && index >= 0, "Index out of bounds");
return names[index]->getPrefix(mode);
MOZ_ASSERT(aIndex < int32_t(mStorage.Length()) && aIndex >= 0,
"Index out of bounds");
return mStorage[aIndex].GetPrefix(mMode);
}
nsHtml5String
nsHtml5HtmlAttributes::getValueNoBoundsCheck(int32_t index)
nsHtml5HtmlAttributes::getValueNoBoundsCheck(int32_t aIndex)
{
MOZ_ASSERT(index < length && index >= 0, "Index out of bounds");
return values[index];
MOZ_ASSERT(aIndex < int32_t(mStorage.Length()) && aIndex >= 0,
"Index out of bounds");
return mStorage[aIndex].GetValue();
}
nsHtml5AttributeName*
nsHtml5HtmlAttributes::getAttributeNameNoBoundsCheck(int32_t index)
int32_t
nsHtml5HtmlAttributes::getLineNoBoundsCheck(int32_t aIndex)
{
MOZ_ASSERT(index < length && index >= 0, "Index out of bounds");
return names[index];
}
int32_t
nsHtml5HtmlAttributes::getLineNoBoundsCheck(int32_t index)
{
MOZ_ASSERT(index < length && index >= 0, "Index out of bounds");
return lines[index];
MOZ_ASSERT(aIndex < int32_t(mStorage.Length()) && aIndex >= 0,
"Index out of bounds");
return mStorage[aIndex].GetLine();
}
void
nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsHtml5String value, int32_t line)
nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* aName,
nsHtml5String aValue,
int32_t aLine)
{
if (names.length == length) {
int32_t newLen = length << 1;
jArray<nsHtml5AttributeName*,int32_t> newNames = jArray<nsHtml5AttributeName*,int32_t>::newJArray(newLen);
nsHtml5ArrayCopy::arraycopy(names, newNames, names.length);
names = newNames;
jArray<nsHtml5String,int32_t> newValues = jArray<nsHtml5String,int32_t>::newJArray(newLen);
nsHtml5ArrayCopy::arraycopy(values, newValues, values.length);
values = newValues;
jArray<int32_t,int32_t> newLines = jArray<int32_t,int32_t>::newJArray(newLen);
nsHtml5ArrayCopy::arraycopy(lines, newLines, lines.length);
lines = newLines;
mStorage.AppendElement(nsHtml5AttributeEntry(aName, aValue, aLine));
MOZ_RELEASE_ASSERT(mStorage.Length() <= INT32_MAX,
"Can't handle this many attributes.");
}
// Isindex-only, so doesn't need to deal with SVG and MathML
void
nsHtml5HtmlAttributes::AddAttributeWithLocal(nsIAtom* aName,
nsHtml5String aValue,
int32_t aLine)
{
mStorage.AppendElement(nsHtml5AttributeEntry(aName, aValue, aLine));
MOZ_RELEASE_ASSERT(mStorage.Length() <= INT32_MAX,
"Can't handle this many attributes.");
}
void
nsHtml5HtmlAttributes::clear(int32_t aMode)
{
for (nsHtml5AttributeEntry& entry : mStorage) {
entry.ReleaseValue();
}
names[length] = name;
values[length] = value;
lines[length] = line;
length++;
mStorage.TruncateLength(0);
mMode = aMode;
}
void
nsHtml5HtmlAttributes::clear(int32_t m)
void
nsHtml5HtmlAttributes::releaseValue(int32_t aIndex)
{
for (int32_t i = 0; i < length; i++) {
names[i]->release();
names[i] = nullptr;
values[i].Release();
values[i] = nullptr;
}
length = 0;
mode = m;
}
void
nsHtml5HtmlAttributes::releaseValue(int32_t i)
{
values[i].Release();
mStorage[aIndex].ReleaseValue();
}
void
nsHtml5HtmlAttributes::clearWithoutReleasingContents()
{
for (int32_t i = 0; i < length; i++) {
names[i] = nullptr;
values[i] = nullptr;
}
length = 0;
mStorage.TruncateLength(0);
}
bool
nsHtml5HtmlAttributes::contains(nsHtml5AttributeName* name)
bool
nsHtml5HtmlAttributes::contains(nsHtml5AttributeName* aName)
{
for (int32_t i = 0; i < length; i++) {
if (name->equalsAnother(names[i])) {
for (size_t i = 0; i < mStorage.Length(); i++) {
if (mStorage[i].GetLocal(nsHtml5AttributeName::HTML) ==
aName->getLocal(nsHtml5AttributeName::HTML)) {
return true;
}
}
@ -210,43 +195,44 @@ nsHtml5HtmlAttributes::contains(nsHtml5AttributeName* name)
void
nsHtml5HtmlAttributes::adjustForMath()
{
mode = NS_HTML5ATTRIBUTE_NAME_MATHML;
mMode = nsHtml5AttributeName::MATHML;
}
void
nsHtml5HtmlAttributes::adjustForSvg()
{
mode = NS_HTML5ATTRIBUTE_NAME_SVG;
mMode = nsHtml5AttributeName::SVG;
}
nsHtml5HtmlAttributes*
nsHtml5HtmlAttributes::cloneAttributes(nsHtml5AtomTable* interner)
nsHtml5HtmlAttributes*
nsHtml5HtmlAttributes::cloneAttributes(nsHtml5AtomTable* aInterner)
{
MOZ_ASSERT((!length) || !mode || mode == 3);
nsHtml5HtmlAttributes* clone = new nsHtml5HtmlAttributes(0);
for (int32_t i = 0; i < length; i++) {
clone->addAttribute(names[i]->cloneAttributeName(interner), nsHtml5Portability::newStringFromString(values[i]), lines[i]);
MOZ_ASSERT(mStorage.IsEmpty() || !mMode);
nsHtml5HtmlAttributes* clone =
new nsHtml5HtmlAttributes(nsHtml5AttributeName::HTML);
for (nsHtml5AttributeEntry& entry : mStorage) {
clone->AddEntry(entry.Clone(aInterner));
}
return clone;
}
bool
nsHtml5HtmlAttributes::equalsAnother(nsHtml5HtmlAttributes* other)
bool
nsHtml5HtmlAttributes::equalsAnother(nsHtml5HtmlAttributes* aOther)
{
MOZ_ASSERT(!mode || mode == 3, "Trying to compare attributes in foreign content.");
int32_t otherLength = other->getLength();
if (length != otherLength) {
MOZ_ASSERT(!mMode, "Trying to compare attributes in foreign content.");
if (mStorage.Length() != aOther->mStorage.Length()) {
return false;
}
for (int32_t i = 0; i < length; i++) {
for (nsHtml5AttributeEntry& entry : mStorage) {
bool found = false;
nsIAtom* ownLocal = names[i]->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML);
for (int32_t j = 0; j < otherLength; j++) {
if (ownLocal == other->names[j]->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML)) {
nsIAtom* ownLocal = entry.GetLocal(nsHtml5AttributeName::HTML);
for (nsHtml5AttributeEntry& otherEntry : aOther->mStorage) {
if (ownLocal == otherEntry.GetLocal(nsHtml5AttributeName::HTML)) {
found = true;
if (!nsHtml5Portability::stringEqualsString(values[i], other->values[j])) {
if (!entry.GetValue().Equals(otherEntry.GetValue())) {
return false;
}
break;
}
}
if (!found) {
@ -256,10 +242,16 @@ nsHtml5HtmlAttributes::equalsAnother(nsHtml5HtmlAttributes* other)
return true;
}
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

View file

@ -23,11 +23,6 @@
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit HtmlAttributes.java instead and regenerate.
*/
#ifndef nsHtml5HtmlAttributes_h
#define nsHtml5HtmlAttributes_h
@ -45,6 +40,8 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
#include "nsTArray.h"
#include "nsHtml5AttributeEntry.h"
class nsHtml5StreamParser;
@ -63,32 +60,39 @@ class nsHtml5HtmlAttributes
public:
static nsHtml5HtmlAttributes* EMPTY_ATTRIBUTES;
private:
int32_t mode;
int32_t length;
autoJArray<nsHtml5AttributeName*,int32_t> names;
autoJArray<nsHtml5String,int32_t> values;
autoJArray<int32_t,int32_t> lines;
AutoTArray<nsHtml5AttributeEntry, 5> mStorage;
int32_t mMode;
void AddEntry(nsHtml5AttributeEntry&& aEntry);
public:
explicit nsHtml5HtmlAttributes(int32_t mode);
explicit nsHtml5HtmlAttributes(int32_t aMode);
~nsHtml5HtmlAttributes();
int32_t getIndex(nsHtml5AttributeName* name);
nsHtml5String getValue(nsHtml5AttributeName* name);
// Remove getIndex when removing isindex support
int32_t getIndex(nsHtml5AttributeName* aName);
nsHtml5String getValue(nsHtml5AttributeName* aName);
int32_t getLength();
nsIAtom* getLocalNameNoBoundsCheck(int32_t index);
int32_t getURINoBoundsCheck(int32_t index);
nsIAtom* getPrefixNoBoundsCheck(int32_t index);
nsHtml5String getValueNoBoundsCheck(int32_t index);
nsHtml5AttributeName* getAttributeNameNoBoundsCheck(int32_t index);
int32_t getLineNoBoundsCheck(int32_t index);
void addAttribute(nsHtml5AttributeName* name, nsHtml5String value, int32_t line);
void clear(int32_t m);
void releaseValue(int32_t i);
nsIAtom* getLocalNameNoBoundsCheck(int32_t aIndex);
int32_t getURINoBoundsCheck(int32_t aIndex);
nsIAtom* getPrefixNoBoundsCheck(int32_t aIndex);
nsHtml5String getValueNoBoundsCheck(int32_t aIndex);
nsHtml5AttributeName* getAttributeNameNoBoundsCheck(int32_t aIndex);
int32_t getLineNoBoundsCheck(int32_t aIndex);
void addAttribute(nsHtml5AttributeName* aName,
nsHtml5String aValue,
int32_t aLine);
void AddAttributeWithLocal(nsIAtom* aName,
nsHtml5String aValue,
int32_t aLine);
void clear(int32_t aMode);
void releaseValue(int32_t aIndex);
void clearWithoutReleasingContents();
bool contains(nsHtml5AttributeName* name);
bool contains(nsHtml5AttributeName* aName);
void adjustForMath();
void adjustForSvg();
nsHtml5HtmlAttributes* cloneAttributes(nsHtml5AtomTable* interner);
bool equalsAnother(nsHtml5HtmlAttributes* other);
nsHtml5HtmlAttributes* cloneAttributes(nsHtml5AtomTable* aInterner);
bool equalsAnother(nsHtml5HtmlAttributes* aOther);
static void initializeStatics();
static void releaseStatics();
};

View file

@ -44,12 +44,13 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
#include "nsHtml5Portability.h"
#include "nsHtml5ContentCreatorFunction.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5StackNode.h"
#include "nsHtml5UTF16Buffer.h"
#include "nsHtml5StateSnapshot.h"
@ -68,17 +69,17 @@ staticJArray<char16_t,int32_t> nsHtml5MetaScanner::CONTENT_TYPE = { CONTENT_TYPE
nsHtml5MetaScanner::nsHtml5MetaScanner(nsHtml5TreeBuilder* tb)
: readable(nullptr),
metaState(NS_HTML5META_SCANNER_NO),
metaState(NO),
contentIndex(INT32_MAX),
charsetIndex(INT32_MAX),
httpEquivIndex(INT32_MAX),
contentTypeIndex(INT32_MAX),
stateSave(NS_HTML5META_SCANNER_DATA),
stateSave(DATA),
strBufLen(0),
strBuf(jArray<char16_t,int32_t>::newJArray(36)),
content(nullptr),
charset(nullptr),
httpEquivState(NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN),
httpEquivState(HTTP_EQUIV_NOT_SEEN),
treeBuilder(tb)
{
MOZ_COUNT_CTOR(nsHtml5MetaScanner);
@ -99,7 +100,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
bool reconsume = false;
stateloop: for (; ; ) {
switch(state) {
case NS_HTML5META_SCANNER_DATA: {
case DATA: {
for (; ; ) {
if (reconsume) {
reconsume = false;
@ -111,7 +112,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
NS_HTML5_BREAK(stateloop);
}
case '<': {
state = NS_HTML5META_SCANNER_TAG_OPEN;
state = nsHtml5MetaScanner::TAG_OPEN;
NS_HTML5_BREAK(dataloop);
}
default: {
@ -121,7 +122,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
dataloop_end: ;
}
case NS_HTML5META_SCANNER_TAG_OPEN: {
case TAG_OPEN: {
for (; ; ) {
c = read();
switch(c) {
@ -130,30 +131,30 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
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);
}
@ -161,7 +162,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
tagopenloop_end: ;
}
case NS_HTML5META_SCANNER_TAG_NAME: {
case TAG_NAME: {
for (; ; ) {
c = read();
switch(c) {
@ -172,53 +173,53 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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;
@ -236,14 +237,14 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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':
@ -252,7 +253,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
charsetIndex = 0;
httpEquivIndex = INT32_MAX;
contentTypeIndex = INT32_MAX;
state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME;
state = nsHtml5MetaScanner::ATTRIBUTE_NAME;
NS_HTML5_BREAK(beforeattributenameloop);
}
case 'h':
@ -261,7 +262,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
charsetIndex = INT32_MAX;
httpEquivIndex = 0;
contentTypeIndex = INT32_MAX;
state = NS_HTML5META_SCANNER_ATTRIBUTE_NAME;
state = nsHtml5MetaScanner::ATTRIBUTE_NAME;
NS_HTML5_BREAK(beforeattributenameloop);
}
default: {
@ -269,14 +270,14 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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) {
@ -287,28 +288,28 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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;
}
@ -334,7 +335,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
attributenameloop_end: ;
}
case NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_VALUE: {
case BEFORE_ATTRIBUTE_VALUE: {
for (; ; ) {
c = read();
switch(c) {
@ -348,30 +349,30 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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;
@ -384,7 +385,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
case '\"': {
handleAttributeValue();
state = NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED;
state = nsHtml5MetaScanner::AFTER_ATTRIBUTE_VALUE_QUOTED;
NS_HTML5_BREAK(attributevaluedoublequotedloop);
}
default: {
@ -395,7 +396,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
attributevaluedoublequotedloop_end: ;
}
case NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED: {
case AFTER_ATTRIBUTE_VALUE_QUOTED: {
for (; ; ) {
c = read();
switch(c) {
@ -406,22 +407,22 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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);
}
@ -429,7 +430,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
afterattributevaluequotedloop_end: ;
}
case NS_HTML5META_SCANNER_SELF_CLOSING_START_TAG: {
case SELF_CLOSING_START_TAG: {
c = read();
switch(c) {
case -1: {
@ -439,17 +440,17 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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;
@ -465,7 +466,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
case '\n':
case '\f': {
handleAttributeValue();
state = NS_HTML5META_SCANNER_BEFORE_ATTRIBUTE_NAME;
state = nsHtml5MetaScanner::BEFORE_ATTRIBUTE_NAME;
NS_HTML5_CONTINUE(stateloop);
}
case '>': {
@ -473,7 +474,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
if (handleTag()) {
NS_HTML5_BREAK(stateloop);
}
state = NS_HTML5META_SCANNER_DATA;
state = nsHtml5MetaScanner::DATA;
NS_HTML5_CONTINUE(stateloop);
}
default: {
@ -483,7 +484,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
}
}
case NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_NAME: {
case AFTER_ATTRIBUTE_NAME: {
for (; ; ) {
c = read();
switch(c) {
@ -498,13 +499,13 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
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 '>': {
@ -512,26 +513,26 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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) {
@ -539,11 +540,11 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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);
}
@ -551,7 +552,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
markupdeclarationopenloop_end: ;
}
case NS_HTML5META_SCANNER_MARKUP_DECLARATION_HYPHEN: {
case MARKUP_DECLARATION_HYPHEN: {
for (; ; ) {
c = read();
switch(c) {
@ -559,11 +560,11 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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);
}
@ -571,7 +572,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
markupdeclarationhyphenloop_end: ;
}
case NS_HTML5META_SCANNER_COMMENT_START: {
case COMMENT_START: {
for (; ; ) {
c = read();
switch(c) {
@ -579,22 +580,22 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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) {
@ -602,7 +603,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
NS_HTML5_BREAK(stateloop);
}
case '-': {
state = NS_HTML5META_SCANNER_COMMENT_END_DASH;
state = nsHtml5MetaScanner::COMMENT_END_DASH;
NS_HTML5_BREAK(commentloop);
}
default: {
@ -612,7 +613,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
commentloop_end: ;
}
case NS_HTML5META_SCANNER_COMMENT_END_DASH: {
case COMMENT_END_DASH: {
for (; ; ) {
c = read();
switch(c) {
@ -620,18 +621,18 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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) {
@ -639,40 +640,40 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
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;
@ -685,7 +686,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
case '\'': {
handleAttributeValue();
state = NS_HTML5META_SCANNER_AFTER_ATTRIBUTE_VALUE_QUOTED;
state = nsHtml5MetaScanner::AFTER_ATTRIBUTE_VALUE_QUOTED;
NS_HTML5_CONTINUE(stateloop);
}
default: {
@ -695,7 +696,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
}
}
}
case NS_HTML5META_SCANNER_SCAN_UNTIL_GT: {
case SCAN_UNTIL_GT: {
for (; ; ) {
if (reconsume) {
reconsume = false;
@ -707,7 +708,7 @@ nsHtml5MetaScanner::stateLoop(int32_t state)
NS_HTML5_BREAK(stateloop);
}
case '>': {
state = NS_HTML5META_SCANNER_DATA;
state = nsHtml5MetaScanner::DATA;
NS_HTML5_CONTINUE(stateloop);
}
default: {
@ -725,7 +726,7 @@ nsHtml5MetaScanner::stateLoop(int32_t 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) {
@ -752,7 +753,7 @@ nsHtml5MetaScanner::addToBuffer(int32_t c)
void
nsHtml5MetaScanner::handleAttributeValue()
{
if (metaState != NS_HTML5META_SCANNER_A) {
if (metaState != A) {
return;
}
if (contentIndex == CONTENT.length && !content) {
@ -763,8 +764,8 @@ nsHtml5MetaScanner::handleAttributeValue()
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;
}
}
@ -777,7 +778,7 @@ nsHtml5MetaScanner::handleTag()
content = nullptr;
charset.Release();
charset = nullptr;
httpEquivState = NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN;
httpEquivState = HTTP_EQUIV_NOT_SEEN;
return stop;
}
@ -787,7 +788,7 @@ 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;

View file

@ -45,14 +45,15 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
#include "nsHtml5Portability.h"
#include "nsHtml5ContentCreatorFunction.h"
class nsHtml5StreamParser;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot;
class nsHtml5Portability;
@ -65,6 +66,62 @@ class nsHtml5MetaScanner
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:
@ -110,35 +167,5 @@ class nsHtml5MetaScanner
#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

View file

@ -44,15 +44,15 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
#include "nsHtml5ContentCreatorFunction.h"
class nsHtml5StreamParser;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5MetaScanner;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot;
@ -77,7 +77,5 @@ class nsHtml5Portability
static void releaseStatics();
};
#endif

View file

@ -1,34 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsHtml5ReleasableAttributeName.h"
#include "nsHtml5Portability.h"
#include "nsHtml5AtomTable.h"
nsHtml5ReleasableAttributeName::nsHtml5ReleasableAttributeName(int32_t* uri, nsIAtom** local, nsIAtom** prefix)
: nsHtml5AttributeName(uri, local, prefix)
{
}
nsHtml5AttributeName*
nsHtml5ReleasableAttributeName::cloneAttributeName(nsHtml5AtomTable* aInterner)
{
nsIAtom* l = getLocal(0);
if (aInterner) {
if (!l->IsStaticAtom()) {
nsAutoString str;
l->ToString(str);
l = aInterner->GetAtom(str);
}
}
return new nsHtml5ReleasableAttributeName(nsHtml5AttributeName::ALL_NO_NS,
nsHtml5AttributeName::SAME_LOCAL(l),
nsHtml5AttributeName::ALL_NO_PREFIX);
}
void
nsHtml5ReleasableAttributeName::release()
{
delete this;
}

View file

@ -1,21 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsHtml5ReleasableAttributeName_h
#define nsHtml5ReleasableAttributeName_h
#include "nsHtml5AttributeName.h"
#include "mozilla/Attributes.h"
class nsHtml5AtomTable;
class nsHtml5ReleasableAttributeName final : public nsHtml5AttributeName
{
public:
nsHtml5ReleasableAttributeName(int32_t* uri, nsIAtom** local, nsIAtom** prefix);
virtual nsHtml5AttributeName* cloneAttributeName(nsHtml5AtomTable* aInterner);
virtual void release();
};
#endif // nsHtml5ReleasableAttributeName_h

View file

@ -1,30 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsHtml5ReleasableElementName.h"
nsHtml5ReleasableElementName::nsHtml5ReleasableElementName(nsIAtom* name)
: nsHtml5ElementName(name)
{
}
void
nsHtml5ReleasableElementName::release()
{
delete this;
}
nsHtml5ElementName*
nsHtml5ReleasableElementName::cloneElementName(nsHtml5AtomTable* aInterner)
{
nsIAtom* l = name;
if (aInterner) {
if (!l->IsStaticAtom()) {
nsAutoString str;
l->ToString(str);
l = aInterner->GetAtom(str);
}
}
return new nsHtml5ReleasableElementName(l);
}

View file

@ -1,19 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsHtml5ReleasableElementName_h
#define nsHtml5ReleasableElementName_h
#include "nsHtml5ElementName.h"
#include "mozilla/Attributes.h"
class nsHtml5ReleasableElementName final : public nsHtml5ElementName
{
public:
explicit nsHtml5ReleasableElementName(nsIAtom* name);
virtual void release();
virtual nsHtml5ElementName* cloneElementName(nsHtml5AtomTable* interner);
};
#endif // nsHtml5ReleasableElementName_h

View file

@ -44,13 +44,14 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
#include "nsHtml5Portability.h"
#include "nsHtml5ContentCreatorFunction.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5MetaScanner.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5UTF16Buffer.h"
#include "nsHtml5StateSnapshot.h"
#include "nsHtml5Portability.h"
@ -60,147 +61,131 @@
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 idxInTreeBuilder)
: idxInTreeBuilder(idxInTreeBuilder)
, refcount(0)
mozilla::dom::HTMLContentCreatorFunction
nsHtml5StackNode::getHtmlCreator()
{
return htmlCreator;
}
nsHtml5StackNode::nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContentHandle* node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes, mozilla::dom::HTMLContentCreatorFunction htmlCreator)
: flags(flags),
name(name),
popName(popName),
ns(ns),
node(node),
attributes(attributes),
refcount(1),
htmlCreator(htmlCreator)
{
MOZ_COUNT_CTOR(nsHtml5StackNode);
}
void
nsHtml5StackNode::setValues(int32_t flags,
int32_t ns,
nsIAtom* name,
nsIContentHandle* node,
nsIAtom* popName,
nsHtml5HtmlAttributes* attributes)
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node)
: flags(elementName->getFlags()),
name(elementName->getName()),
popName(elementName->getName()),
ns(kNameSpaceID_XHTML),
node(node),
attributes(nullptr),
refcount(1),
htmlCreator(nullptr)
{
MOZ_ASSERT(isUnused());
this->flags = flags;
this->name = name;
this->popName = popName;
this->ns = ns;
this->node = node;
this->attributes = attributes;
this->refcount = 1;
}
void
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
nsIContentHandle* node)
{
MOZ_ASSERT(isUnused());
this->flags = elementName->getFlags();
this->name = elementName->name;
this->popName = elementName->name;
this->ns = kNameSpaceID_XHTML;
this->node = node;
this->attributes = nullptr;
this->refcount = 1;
MOZ_ASSERT(!elementName->isCustom(), "Don't use this constructor for custom elements.");
MOZ_COUNT_CTOR(nsHtml5StackNode);
MOZ_ASSERT(elementName->isInterned(), "Don't use this constructor for custom elements.");
}
void
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
nsIContentHandle* node,
nsHtml5HtmlAttributes* attributes)
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsHtml5HtmlAttributes* attributes)
: flags(elementName->getFlags()),
name(elementName->getName()),
popName(elementName->getName()),
ns(kNameSpaceID_XHTML),
node(node),
attributes(attributes),
refcount(1),
htmlCreator(elementName->getHtmlCreator())
{
MOZ_ASSERT(isUnused());
this->flags = elementName->getFlags();
this->name = elementName->name;
this->popName = elementName->name;
this->ns = kNameSpaceID_XHTML;
this->node = node;
this->attributes = attributes;
this->refcount = 1;
MOZ_ASSERT(!elementName->isCustom(), "Don't use this constructor for custom elements.");
MOZ_COUNT_CTOR(nsHtml5StackNode);
MOZ_ASSERT(elementName->isInterned(), "Don't use this constructor for custom elements.");
}
void
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
nsIContentHandle* node,
nsIAtom* popName)
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName)
: flags(elementName->getFlags()),
name(elementName->getName()),
popName(popName),
ns(kNameSpaceID_XHTML),
node(node),
attributes(nullptr),
refcount(1),
htmlCreator(nullptr)
{
MOZ_ASSERT(isUnused());
this->flags = elementName->getFlags();
this->name = elementName->name;
this->popName = popName;
this->ns = kNameSpaceID_XHTML;
this->node = node;
this->attributes = nullptr;
this->refcount = 1;
MOZ_COUNT_CTOR(nsHtml5StackNode);
}
void
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
nsIAtom* popName,
nsIContentHandle* node)
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContentHandle* node)
: flags(prepareSvgFlags(elementName->getFlags())),
name(elementName->getName()),
popName(popName),
ns(kNameSpaceID_SVG),
node(node),
attributes(nullptr),
refcount(1),
htmlCreator(nullptr)
{
MOZ_ASSERT(isUnused());
this->flags = prepareSvgFlags(elementName->getFlags());
this->name = elementName->name;
this->popName = popName;
this->ns = kNameSpaceID_SVG;
this->node = node;
this->attributes = nullptr;
this->refcount = 1;
MOZ_COUNT_CTOR(nsHtml5StackNode);
}
void
nsHtml5StackNode::setValues(nsHtml5ElementName* elementName,
nsIContentHandle* node,
nsIAtom* popName,
bool markAsIntegrationPoint)
nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName, bool markAsIntegrationPoint)
: flags(prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint)),
name(elementName->getName()),
popName(popName),
ns(kNameSpaceID_MathML),
node(node),
attributes(nullptr),
refcount(1),
htmlCreator(nullptr)
{
MOZ_ASSERT(isUnused());
this->flags =
prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint);
this->name = elementName->name;
this->popName = popName;
this->ns = kNameSpaceID_MathML;
this->node = node;
this->attributes = nullptr;
this->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;
}
@ -208,12 +193,12 @@ nsHtml5StackNode::prepareSvgFlags(int32_t 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;
}
@ -222,6 +207,7 @@ nsHtml5StackNode::prepareMathFlags(int32_t flags, bool markAsIntegrationPoint)
nsHtml5StackNode::~nsHtml5StackNode()
{
MOZ_COUNT_DTOR(nsHtml5StackNode);
delete attributes;
}
void
@ -236,28 +222,15 @@ nsHtml5StackNode::retain()
refcount++;
}
void
nsHtml5StackNode::release(nsHtml5TreeBuilder* owningTreeBuilder)
void
nsHtml5StackNode::release()
{
refcount--;
MOZ_ASSERT(refcount >= 0);
if (!refcount) {
delete attributes;
if (idxInTreeBuilder >= 0) {
owningTreeBuilder->notifyUnusedStackNode(idxInTreeBuilder);
} else {
MOZ_ASSERT(!owningTreeBuilder);
delete this;
}
delete this;
}
}
bool
nsHtml5StackNode::isUnused()
{
return !refcount;
}
void
nsHtml5StackNode::initializeStatics()
{

View file

@ -45,15 +45,16 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
#include "nsHtml5Portability.h"
#include "nsHtml5ContentCreatorFunction.h"
class nsHtml5StreamParser;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5MetaScanner;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot;
class nsHtml5Portability;
@ -62,7 +63,6 @@ class nsHtml5Portability;
class nsHtml5StackNode
{
public:
int32_t idxInTreeBuilder;
int32_t flags;
nsIAtom* name;
nsIAtom* popName;
@ -71,6 +71,7 @@ class nsHtml5StackNode
nsHtml5HtmlAttributes* attributes;
private:
int32_t refcount;
mozilla::dom::HTMLContentCreatorFunction htmlCreator;
public:
inline int32_t getFlags()
{
@ -82,28 +83,13 @@ class nsHtml5StackNode
bool isSpecial();
bool isFosterParenting();
bool isHtmlIntegrationPoint();
explicit nsHtml5StackNode(int32_t idxInTreeBuilder);
void setValues(int32_t flags,
int32_t ns,
nsIAtom* name,
nsIContentHandle* node,
nsIAtom* popName,
nsHtml5HtmlAttributes* attributes);
void setValues(nsHtml5ElementName* elementName, nsIContentHandle* node);
void setValues(nsHtml5ElementName* elementName,
nsIContentHandle* node,
nsHtml5HtmlAttributes* attributes);
void setValues(nsHtml5ElementName* elementName,
nsIContentHandle* node,
nsIAtom* popName);
void setValues(nsHtml5ElementName* elementName,
nsIAtom* popName,
nsIContentHandle* node);
void setValues(nsHtml5ElementName* elementName,
nsIContentHandle* node,
nsIAtom* popName,
bool markAsIntegrationPoint);
mozilla::dom::HTMLContentCreatorFunction getHtmlCreator();
nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContentHandle* node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes, mozilla::dom::HTMLContentCreatorFunction htmlCreator);
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node);
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsHtml5HtmlAttributes* attributes);
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName);
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContentHandle* node);
nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName, bool markAsIntegrationPoint);
private:
static int32_t prepareSvgFlags(int32_t flags);
static int32_t prepareMathFlags(int32_t flags, bool markAsIntegrationPoint);
@ -111,13 +97,10 @@ class nsHtml5StackNode
~nsHtml5StackNode();
void dropAttributes();
void retain();
void release(nsHtml5TreeBuilder* owningTreeBuilder);
bool isUnused();
void release();
static void initializeStatics();
static void releaseStatics();
};
#endif

View file

@ -43,13 +43,14 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
#include "nsHtml5Portability.h"
#include "nsHtml5ContentCreatorFunction.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5MetaScanner.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5StackNode.h"
#include "nsHtml5UTF16Buffer.h"
#include "nsHtml5Portability.h"

View file

@ -44,15 +44,16 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
#include "nsHtml5Portability.h"
#include "nsHtml5ContentCreatorFunction.h"
class nsHtml5StreamParser;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5MetaScanner;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer;
class nsHtml5Portability;
@ -92,7 +93,5 @@ class nsHtml5StateSnapshot : public nsAHtml5TreeBuilderState
static void releaseStatics();
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -51,11 +51,10 @@
class nsHtml5StreamParser;
class nsHtml5TreeBuilder;
class nsHtml5MetaScanner;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5TreeBuilder;
class nsHtml5MetaScanner;
class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot;
class nsHtml5Portability;
@ -64,6 +63,162 @@ 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[];
@ -123,10 +278,13 @@ class nsHtml5Tokenizer
protected:
bool endTag;
private:
bool containsHyphen;
nsHtml5ElementName* tagName;
nsHtml5ElementName* nonInternedTagName;
protected:
nsHtml5AttributeName* attributeName;
private:
nsHtml5AttributeName* nonInternedAttributeName;
nsIAtom* doctypeName;
nsHtml5String publicIdentifier;
nsHtml5String systemIdentifier;
@ -306,84 +464,5 @@ class nsHtml5Tokenizer
#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

View file

@ -62,7 +62,7 @@ nsHtml5Tokenizer::EnsureBufferSpace(int32_t aLength)
void
nsHtml5Tokenizer::StartPlainText()
{
stateSave = NS_HTML5TOKENIZER_PLAINTEXT;
stateSave = nsHtml5Tokenizer::PLAINTEXT;
}
void

File diff suppressed because it is too large Load diff

View file

@ -61,11 +61,10 @@
class nsHtml5StreamParser;
class nsHtml5Tokenizer;
class nsHtml5MetaScanner;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5Tokenizer;
class nsHtml5MetaScanner;
class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot;
class nsHtml5Portability;
@ -75,7 +74,217 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
{
private:
static char16_t REPLACEMENT_CHARACTER[];
public:
static const int32_t OTHER = 0;
static const int32_t A = 1;
static const int32_t BASE = 2;
static const int32_t BODY = 3;
static const int32_t BR = 4;
static const int32_t BUTTON = 5;
static const int32_t CAPTION = 6;
static const int32_t COL = 7;
static const int32_t COLGROUP = 8;
static const int32_t FORM = 9;
static const int32_t FRAME = 10;
static const int32_t FRAMESET = 11;
static const int32_t IMAGE = 12;
static const int32_t INPUT = 13;
static const int32_t ISINDEX = 14;
static const int32_t LI = 15;
static const int32_t LINK_OR_BASEFONT_OR_BGSOUND = 16;
static const int32_t MATH = 17;
static const int32_t META = 18;
static const int32_t SVG = 19;
static const int32_t HEAD = 20;
static const int32_t HR = 22;
static const int32_t HTML = 23;
static const int32_t NOBR = 24;
static const int32_t NOFRAMES = 25;
static const int32_t NOSCRIPT = 26;
static const int32_t OPTGROUP = 27;
static const int32_t OPTION = 28;
static const int32_t P = 29;
static const int32_t PLAINTEXT = 30;
static const int32_t SCRIPT = 31;
static const int32_t SELECT = 32;
static const int32_t STYLE = 33;
static const int32_t TABLE = 34;
static const int32_t TEXTAREA = 35;
static const int32_t TITLE = 36;
static const int32_t TR = 37;
static const int32_t XMP = 38;
static const int32_t TBODY_OR_THEAD_OR_TFOOT = 39;
static const int32_t TD_OR_TH = 40;
static const int32_t DD_OR_DT = 41;
static const int32_t H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 = 42;
static const int32_t MARQUEE_OR_APPLET = 43;
static const int32_t PRE_OR_LISTING = 44;
static const int32_t B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U = 45;
static const int32_t UL_OR_OL_OR_DL = 46;
static const int32_t IFRAME = 47;
static const int32_t EMBED = 48;
static const int32_t AREA_OR_WBR = 49;
static const int32_t DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU = 50;
static const int32_t 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 = 51;
static const int32_t RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR = 52;
static const int32_t RB_OR_RTC = 53;
static const int32_t PARAM_OR_SOURCE_OR_TRACK = 55;
static const int32_t MGLYPH_OR_MALIGNMARK = 56;
static const int32_t MI_MO_MN_MS_MTEXT = 57;
static const int32_t ANNOTATION_XML = 58;
static const int32_t FOREIGNOBJECT_OR_DESC = 59;
static const int32_t NOEMBED = 60;
static const int32_t FIELDSET = 61;
static const int32_t OUTPUT = 62;
static const int32_t OBJECT = 63;
static const int32_t FONT = 64;
static const int32_t KEYGEN = 65;
static const int32_t MENUITEM = 66;
static const int32_t TEMPLATE = 67;
static const int32_t IMG = 68;
static const int32_t RT_OR_RP = 69;
private:
static const int32_t IN_ROW = 0;
static const int32_t IN_TABLE_BODY = 1;
static const int32_t IN_TABLE = 2;
static const int32_t IN_CAPTION = 3;
static const int32_t IN_CELL = 4;
static const int32_t FRAMESET_OK = 5;
static const int32_t IN_BODY = 6;
static const int32_t IN_HEAD = 7;
static const int32_t IN_HEAD_NOSCRIPT = 8;
static const int32_t IN_COLUMN_GROUP = 9;
static const int32_t IN_SELECT_IN_TABLE = 10;
static const int32_t IN_SELECT = 11;
static const int32_t AFTER_BODY = 12;
static const int32_t IN_FRAMESET = 13;
static const int32_t AFTER_FRAMESET = 14;
static const int32_t INITIAL = 15;
static const int32_t BEFORE_HTML = 16;
static const int32_t BEFORE_HEAD = 17;
static const int32_t AFTER_HEAD = 18;
static const int32_t AFTER_AFTER_BODY = 19;
static const int32_t AFTER_AFTER_FRAMESET = 20;
static const int32_t TEXT = 21;
static const int32_t IN_TEMPLATE = 22;
static const int32_t CHARSET_INITIAL = 0;
static const int32_t CHARSET_C = 1;
static const int32_t CHARSET_H = 2;
static const int32_t CHARSET_A = 3;
static const int32_t CHARSET_R = 4;
static const int32_t CHARSET_S = 5;
static const int32_t CHARSET_E = 6;
static const int32_t CHARSET_T = 7;
static const int32_t CHARSET_EQUALS = 8;
static const int32_t CHARSET_SINGLE_QUOTED = 9;
static const int32_t CHARSET_DOUBLE_QUOTED = 10;
static const int32_t CHARSET_UNQUOTED = 11;
static staticJArray<const char*,int32_t> QUIRKY_PUBLIC_IDS;
static const int32_t NOT_FOUND_ON_STACK = INT32_MAX;
int32_t mode;
int32_t originalMode;
bool framesetOk;
@ -106,6 +315,20 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
private:
bool quirks;
bool isSrcdocDocument;
inline nsHtml5ContentCreatorFunction htmlCreator(mozilla::dom::HTMLContentCreatorFunction htmlCreator)
{
nsHtml5ContentCreatorFunction creator;
creator.html = htmlCreator;
return creator;
}
inline nsHtml5ContentCreatorFunction svgCreator(mozilla::dom::SVGContentCreatorFunction svgCreator)
{
nsHtml5ContentCreatorFunction creator;
creator.svg = svgCreator;
return creator;
}
public:
void startTokenization(nsHtml5Tokenizer* self);
void doctype(nsIAtom* name, nsHtml5String publicIdentifier, nsHtml5String systemIdentifier, bool forceQuirks);
@ -209,8 +432,8 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
nsIAtom* popName,
bool markAsIntegrationPoint);
void insertIntoFosterParent(nsIContentHandle* child);
nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes);
nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsHtml5ContentCreatorFunction creator);
nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsHtml5ContentCreatorFunction creator);
bool isInStack(nsHtml5StackNode* node);
void popTemplateMode();
void pop();
@ -229,24 +452,24 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
bool annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
void appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
void appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
void appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendVoidElementToCurrentMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendVoidElementToCurrentMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendVoidElementToCurrent(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
void appendVoidInputToCurrent(nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
void appendVoidFormToCurrent(nsHtml5HtmlAttributes* attributes);
protected:
void accumulateCharacters(const char16_t* buf, int32_t start, int32_t length);
void requestSuspension();
nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* intendedParent);
nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* intendedParent);
nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* intendedParent, nsHtml5ContentCreatorFunction creator);
nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* intendedParent, nsHtml5ContentCreatorFunction creator);
nsIContentHandle* createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* attributes);
void detachFromParent(nsIContentHandle* element);
bool hasChildren(nsIContentHandle* element);
void appendElement(nsIContentHandle* child, nsIContentHandle* newParent);
void appendChildrenToNewParent(nsIContentHandle* oldParent, nsIContentHandle* newParent);
void insertFosterParentedChild(nsIContentHandle* child, nsIContentHandle* table, nsIContentHandle* stackParent);
nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* table, nsIContentHandle* stackParent);
nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* table, nsIContentHandle* stackParent, nsHtml5ContentCreatorFunction creator);
;void insertFosterParentedCharacters(char16_t* buf, int32_t start, int32_t length, nsIContentHandle* table, nsIContentHandle* stackParent);
void appendCharacters(nsIContentHandle* parent, char16_t* buf, int32_t start, int32_t length);
void appendIsindexPrompt(nsIContentHandle* parent);
@ -306,111 +529,5 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
#include "nsHtml5TreeBuilderHSupplement.h"
};
#define NS_HTML5TREE_BUILDER_OTHER 0
#define NS_HTML5TREE_BUILDER_A 1
#define NS_HTML5TREE_BUILDER_BASE 2
#define NS_HTML5TREE_BUILDER_BODY 3
#define NS_HTML5TREE_BUILDER_BR 4
#define NS_HTML5TREE_BUILDER_BUTTON 5
#define NS_HTML5TREE_BUILDER_CAPTION 6
#define NS_HTML5TREE_BUILDER_COL 7
#define NS_HTML5TREE_BUILDER_COLGROUP 8
#define NS_HTML5TREE_BUILDER_FORM 9
#define NS_HTML5TREE_BUILDER_FRAME 10
#define NS_HTML5TREE_BUILDER_FRAMESET 11
#define NS_HTML5TREE_BUILDER_IMAGE 12
#define NS_HTML5TREE_BUILDER_INPUT 13
#define NS_HTML5TREE_BUILDER_ISINDEX 14
#define NS_HTML5TREE_BUILDER_LI 15
#define NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND 16
#define NS_HTML5TREE_BUILDER_MATH 17
#define NS_HTML5TREE_BUILDER_META 18
#define NS_HTML5TREE_BUILDER_SVG 19
#define NS_HTML5TREE_BUILDER_HEAD 20
#define NS_HTML5TREE_BUILDER_HR 22
#define NS_HTML5TREE_BUILDER_HTML 23
#define NS_HTML5TREE_BUILDER_NOBR 24
#define NS_HTML5TREE_BUILDER_NOFRAMES 25
#define NS_HTML5TREE_BUILDER_NOSCRIPT 26
#define NS_HTML5TREE_BUILDER_OPTGROUP 27
#define NS_HTML5TREE_BUILDER_OPTION 28
#define NS_HTML5TREE_BUILDER_P 29
#define NS_HTML5TREE_BUILDER_PLAINTEXT 30
#define NS_HTML5TREE_BUILDER_SCRIPT 31
#define NS_HTML5TREE_BUILDER_SELECT 32
#define NS_HTML5TREE_BUILDER_STYLE 33
#define NS_HTML5TREE_BUILDER_TABLE 34
#define NS_HTML5TREE_BUILDER_TEXTAREA 35
#define NS_HTML5TREE_BUILDER_TITLE 36
#define NS_HTML5TREE_BUILDER_TR 37
#define NS_HTML5TREE_BUILDER_XMP 38
#define NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT 39
#define NS_HTML5TREE_BUILDER_TD_OR_TH 40
#define NS_HTML5TREE_BUILDER_DD_OR_DT 41
#define NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 42
#define NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET 43
#define NS_HTML5TREE_BUILDER_PRE_OR_LISTING 44
#define NS_HTML5TREE_BUILDER_B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U 45
#define NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL 46
#define NS_HTML5TREE_BUILDER_IFRAME 47
#define NS_HTML5TREE_BUILDER_EMBED 48
#define NS_HTML5TREE_BUILDER_AREA_OR_WBR 49
#define NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU 50
#define 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 51
#define NS_HTML5TREE_BUILDER_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR 52
#define NS_HTML5TREE_BUILDER_RB_OR_RTC 53
#define NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE_OR_TRACK 55
#define NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK 56
#define NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT 57
#define NS_HTML5TREE_BUILDER_ANNOTATION_XML 58
#define NS_HTML5TREE_BUILDER_FOREIGNOBJECT_OR_DESC 59
#define NS_HTML5TREE_BUILDER_NOEMBED 60
#define NS_HTML5TREE_BUILDER_FIELDSET 61
#define NS_HTML5TREE_BUILDER_OUTPUT 62
#define NS_HTML5TREE_BUILDER_OBJECT 63
#define NS_HTML5TREE_BUILDER_FONT 64
#define NS_HTML5TREE_BUILDER_KEYGEN 65
#define NS_HTML5TREE_BUILDER_MENUITEM 66
#define NS_HTML5TREE_BUILDER_TEMPLATE 67
#define NS_HTML5TREE_BUILDER_IMG 68
#define NS_HTML5TREE_BUILDER_RT_OR_RP 69
#define NS_HTML5TREE_BUILDER_IN_ROW 0
#define NS_HTML5TREE_BUILDER_IN_TABLE_BODY 1
#define NS_HTML5TREE_BUILDER_IN_TABLE 2
#define NS_HTML5TREE_BUILDER_IN_CAPTION 3
#define NS_HTML5TREE_BUILDER_IN_CELL 4
#define NS_HTML5TREE_BUILDER_FRAMESET_OK 5
#define NS_HTML5TREE_BUILDER_IN_BODY 6
#define NS_HTML5TREE_BUILDER_IN_HEAD 7
#define NS_HTML5TREE_BUILDER_IN_HEAD_NOSCRIPT 8
#define NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP 9
#define NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE 10
#define NS_HTML5TREE_BUILDER_IN_SELECT 11
#define NS_HTML5TREE_BUILDER_AFTER_BODY 12
#define NS_HTML5TREE_BUILDER_IN_FRAMESET 13
#define NS_HTML5TREE_BUILDER_AFTER_FRAMESET 14
#define NS_HTML5TREE_BUILDER_INITIAL 15
#define NS_HTML5TREE_BUILDER_BEFORE_HTML 16
#define NS_HTML5TREE_BUILDER_BEFORE_HEAD 17
#define NS_HTML5TREE_BUILDER_AFTER_HEAD 18
#define NS_HTML5TREE_BUILDER_AFTER_AFTER_BODY 19
#define NS_HTML5TREE_BUILDER_AFTER_AFTER_FRAMESET 20
#define NS_HTML5TREE_BUILDER_TEXT 21
#define NS_HTML5TREE_BUILDER_IN_TEMPLATE 22
#define NS_HTML5TREE_BUILDER_CHARSET_INITIAL 0
#define NS_HTML5TREE_BUILDER_CHARSET_C 1
#define NS_HTML5TREE_BUILDER_CHARSET_H 2
#define NS_HTML5TREE_BUILDER_CHARSET_A 3
#define NS_HTML5TREE_BUILDER_CHARSET_R 4
#define NS_HTML5TREE_BUILDER_CHARSET_S 5
#define NS_HTML5TREE_BUILDER_CHARSET_E 6
#define NS_HTML5TREE_BUILDER_CHARSET_T 7
#define NS_HTML5TREE_BUILDER_CHARSET_EQUALS 8
#define NS_HTML5TREE_BUILDER_CHARSET_SINGLE_QUOTED 9
#define NS_HTML5TREE_BUILDER_CHARSET_DOUBLE_QUOTED 10
#define NS_HTML5TREE_BUILDER_CHARSET_UNQUOTED 11
#define NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK INT32_MAX
#endif

View file

@ -68,9 +68,11 @@ nsHtml5TreeBuilder::~nsHtml5TreeBuilder()
}
nsIContentHandle*
nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
nsHtml5TreeBuilder::createElement(int32_t aNamespace,
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
nsIContentHandle* aIntendedParent)
nsIContentHandle* aIntendedParent,
nsHtml5ContentCreatorFunction aCreator)
{
NS_PRECONDITION(aAttributes, "Got null attributes.");
NS_PRECONDITION(aName, "Got null name.");
@ -91,13 +93,28 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
intendedParent->OwnerDoc()->NodeInfoManager() :
mBuilder->GetNodeInfoManager();
nsIContent* elem =
nsHtml5TreeOperation::CreateElement(aNamespace,
name,
aAttributes,
mozilla::dom::FROM_PARSER_FRAGMENT,
nodeInfoManager,
mBuilder);
nsIContent* elem;
if (aNamespace == kNameSpaceID_XHTML) {
elem = nsHtml5TreeOperation::CreateHTMLElement(
name,
aAttributes,
mozilla::dom::FROM_PARSER_FRAGMENT,
nodeInfoManager,
mBuilder,
aCreator.html);
} else if (aNamespace == kNameSpaceID_SVG) {
elem = nsHtml5TreeOperation::CreateSVGElement(
name,
aAttributes,
mozilla::dom::FROM_PARSER_FRAGMENT,
nodeInfoManager,
mBuilder,
aCreator.svg);
} else {
MOZ_ASSERT(aNamespace == kNameSpaceID_MathML);
elem = nsHtml5TreeOperation::CreateMathMLElement(
name, aAttributes, nodeInfoManager, mBuilder);
}
if (MOZ_UNLIKELY(aAttributes != tokenizer->GetAttributes() &&
aAttributes != nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES)) {
delete aAttributes;
@ -113,7 +130,8 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
aAttributes,
content,
aIntendedParent,
!!mSpeculativeLoadStage);
!!mSpeculativeLoadStage,
aCreator);
// mSpeculativeLoadStage is non-null only in the off-the-main-thread
// tree builder, which handles the network stream
@ -173,7 +191,7 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
type,
crossOrigin,
integrity,
mode == NS_HTML5TREE_BUILDER_IN_HEAD);
mode == nsHtml5TreeBuilder::IN_HEAD);
mCurrentHtmlScriptIsAsyncOrDefer =
aAttributes->contains(nsHtml5AttributeName::ATTR_ASYNC) ||
aAttributes->contains(nsHtml5AttributeName::ATTR_DEFER);
@ -279,7 +297,7 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
type,
crossOrigin,
integrity,
mode == NS_HTML5TREE_BUILDER_IN_HEAD);
mode == nsHtml5TreeBuilder::IN_HEAD);
}
} else if (nsHtml5Atoms::style == aName) {
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
@ -345,13 +363,15 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
}
nsIContentHandle*
nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
nsHtml5TreeBuilder::createElement(int32_t aNamespace,
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
nsIContentHandle* aFormElement,
nsIContentHandle* aIntendedParent)
nsIContentHandle* aIntendedParent,
nsHtml5ContentCreatorFunction aCreator)
{
nsIContentHandle* content = createElement(aNamespace, aName, aAttributes,
aIntendedParent);
nsIContentHandle* content =
createElement(aNamespace, aName, aAttributes, aIntendedParent, aCreator);
if (aFormElement) {
if (mBuilder) {
nsHtml5TreeOperation::SetFormElement(static_cast<nsIContent*>(content),
@ -368,10 +388,11 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
nsIContentHandle*
nsHtml5TreeBuilder::createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* aAttributes)
{
nsIContentHandle* content = createElement(kNameSpaceID_XHTML,
nsHtml5Atoms::html,
aAttributes,
nullptr);
nsHtml5ContentCreatorFunction creator;
// <html> uses NS_NewHTMLSharedElement creator
creator.html = NS_NewHTMLSharedElement;
nsIContentHandle* content = createElement(
kNameSpaceID_XHTML, nsHtml5Atoms::html, aAttributes, nullptr, creator);
if (mBuilder) {
nsresult rv = nsHtml5TreeOperation::AppendToDocument(static_cast<nsIContent*>(content),
mBuilder);
@ -387,11 +408,13 @@ nsHtml5TreeBuilder::createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* aAttribute
}
nsIContentHandle*
nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t aNamespace, nsIAtom* aName,
nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t aNamespace,
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
nsIContentHandle* aFormElement,
nsIContentHandle* aTable,
nsIContentHandle* aStackParent)
nsIContentHandle* aStackParent,
nsHtml5ContentCreatorFunction aCreator)
{
NS_PRECONDITION(aTable, "Null table");
NS_PRECONDITION(aStackParent, "Null stack parent");
@ -403,8 +426,8 @@ nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t aNamespace, nsI
static_cast<nsIContent*>(aTable),
static_cast<nsIContent*>(aStackParent));
nsIContentHandle* child = createElement(aNamespace, aName, aAttributes,
aFormElement, fosterParent);
nsIContentHandle* child = createElement(
aNamespace, aName, aAttributes, aFormElement, fosterParent, aCreator);
insertFosterParentedChild(child, aTable, aStackParent);
@ -420,8 +443,8 @@ nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t aNamespace, nsI
aStackParent, fosterParentHandle);
// Create the element with the correct intended parent.
nsIContentHandle* child = createElement(aNamespace, aName, aAttributes,
aFormElement, fosterParentHandle);
nsIContentHandle* child = createElement(
aNamespace, aName, aAttributes, aFormElement, fosterParentHandle, aCreator);
// Insert the child into the foster parent.
insertFosterParentedChild(child, aTable, aStackParent);

View file

@ -24,6 +24,7 @@
#include "nsIFormControl.h"
#include "nsIStyleSheetLinkingElement.h"
#include "nsIDOMDocumentType.h"
#include "DocGroup.h"
#include "nsIObserverService.h"
#include "mozilla/Services.h"
#include "nsIMutationObserver.h"
@ -74,6 +75,29 @@ class MOZ_STACK_CLASS nsHtml5OtherDocUpdate {
nsCOMPtr<nsIDocument> mDocument;
};
/**
* Helper class to temporary break out of the document update batch. Use this
* with caution as this will cause blocked scripts to run.
*/
class MOZ_RAII mozAutoPauseContentUpdate final
{
public:
explicit mozAutoPauseContentUpdate(nsIDocument* aDocument)
: mDocument(aDocument)
{
MOZ_ASSERT(mDocument);
mDocument->EndUpdate(UPDATE_CONTENT_MODEL);
}
~mozAutoPauseContentUpdate()
{
mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
}
private:
nsCOMPtr<nsIDocument> mDocument;
};
nsHtml5TreeOperation::nsHtml5TreeOperation()
: mOpCode(eTreeOpUninitialized)
{
@ -88,8 +112,11 @@ nsHtml5TreeOperation::~nsHtml5TreeOperation()
case eTreeOpAddAttributes:
delete mTwo.attributes;
break;
case eTreeOpCreateElementNetwork:
case eTreeOpCreateElementNotNetwork:
case eTreeOpCreateHTMLElementNetwork:
case eTreeOpCreateHTMLElementNotNetwork:
case eTreeOpCreateSVGElementNetwork:
case eTreeOpCreateSVGElementNotNetwork:
case eTreeOpCreateMathMLElement:
delete mThree.attributes;
break;
case eTreeOpAppendDoctypeToDocument:
@ -329,79 +356,222 @@ nsHtml5TreeOperation::AddAttributes(nsIContent* aNode,
return NS_OK;
}
nsIContent*
nsHtml5TreeOperation::CreateElement(int32_t aNs,
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
mozilla::dom::FromParser aFromParser,
nsNodeInfoManager* aNodeInfoManager,
nsHtml5DocumentBuilder* aBuilder)
void
nsHtml5TreeOperation::SetHTMLElementAttributes(dom::Element* aElement,
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes)
{
bool isKeygen = (aName == nsHtml5Atoms::keygen && aNs == kNameSpaceID_XHTML);
if (MOZ_UNLIKELY(isKeygen)) {
aName = nsHtml5Atoms::select;
int32_t len = aAttributes->getLength();
for (int32_t i = 0; i < len; i++) {
// prefix doesn't need regetting. it is always null or a static atom
// local name is never null
nsCOMPtr<nsIAtom> localName =
Reget(aAttributes->getLocalNameNoBoundsCheck(i));
nsCOMPtr<nsIAtom> prefix = aAttributes->getPrefixNoBoundsCheck(i);
int32_t nsuri = aAttributes->getURINoBoundsCheck(i);
nsString value; // Not Auto, because using it to hold nsStringBuffer*
aAttributes->getValueNoBoundsCheck(i).ToString(value);
if (nsHtml5Atoms::a == aName && nsHtml5Atoms::name == localName) {
// This is an HTML5-incompliant Geckoism.
// Remove when fixing bug 582361
NS_ConvertUTF16toUTF8 cname(value);
NS_ConvertUTF8toUTF16 uv(nsUnescape(cname.BeginWriting()));
aElement->SetAttr(nsuri,
localName,
prefix,
uv,
false);
} else {
aElement->SetAttr(nsuri,
localName,
prefix,
value,
false);
}
}
}
nsCOMPtr<dom::Element> newElement;
RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->
GetNodeInfo(aName, nullptr, aNs, nsIDOMNode::ELEMENT_NODE);
NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
NS_NewElement(getter_AddRefs(newElement),
nodeInfo.forget(),
aFromParser);
NS_ASSERTION(newElement, "Element creation created null pointer.");
nsIContent*
nsHtml5TreeOperation::CreateHTMLElement(
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
mozilla::dom::FromParser aFromParser,
nsNodeInfoManager* aNodeInfoManager,
nsHtml5DocumentBuilder* aBuilder,
mozilla::dom::HTMLContentCreatorFunction aCreator)
{
bool isKeygen = (aName == nsHtml5Atoms::keygen);
if (MOZ_UNLIKELY(isKeygen)) {
aName = nsHtml5Atoms::select;
aCreator = NS_NewHTMLSelectElement;
}
dom::Element* newContent = newElement;
RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
aName, nullptr, kNameSpaceID_XHTML, nsIDOMNode::ELEMENT_NODE);
NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
dom::Element* newContent = nullptr;
nsIDocument* document = nodeInfo->GetDocument();
bool willExecuteScript = false;
bool isCustomElement = false;
nsString isValue;
dom::CustomElementDefinition* definition = nullptr;
// Avoid overhead by checking if custom elements pref is enabled or not.
if (nsContentUtils::IsCustomElementsEnabled()) {
if (aAttributes) {
nsHtml5String is = aAttributes->getValue(nsHtml5AttributeName::ATTR_IS);
if (is) {
is.ToString(isValue);
}
}
isCustomElement = (aCreator == NS_NewCustomElement || !isValue.IsEmpty());
if (isCustomElement && aFromParser != dom::FROM_PARSER_FRAGMENT) {
RefPtr<nsIAtom> tagAtom = nodeInfo->NameAtom();
RefPtr<nsIAtom> typeAtom =
isValue.IsEmpty() ? tagAtom : NS_Atomize(isValue);
MOZ_ASSERT(nodeInfo->NameAtom()->Equals(nodeInfo->LocalName()));
definition = nsContentUtils::LookupCustomElementDefinition(document,
nodeInfo->NameAtom(), nodeInfo->NamespaceID(), typeAtom);
if (definition) {
willExecuteScript = true;
}
}
}
if (willExecuteScript) { // This will cause custom element constructors to run
AutoSetThrowOnDynamicMarkupInsertionCounter
throwOnDynamicMarkupInsertionCounter(document);
mozAutoPauseContentUpdate autoPauseContentUpdate(document);
{
nsAutoMicroTask mt;
}
dom::AutoCEReaction
autoCEReaction(document->GetDocGroup()->CustomElementReactionsStack(),
nullptr);
nsCOMPtr<dom::Element> newElement;
NS_NewHTMLElement(getter_AddRefs(newElement), nodeInfo.forget(),
aFromParser, (isValue.IsEmpty() ? nullptr : &isValue),
definition);
MOZ_ASSERT(newElement, "Element creation created null pointer.");
newContent = newElement;
aBuilder->HoldElement(newElement.forget());
if (MOZ_UNLIKELY(aName == nsHtml5Atoms::style || aName == nsHtml5Atoms::link)) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(newContent));
if (ssle) {
ssle->InitStyleLinkElement(false);
ssle->SetEnableUpdates(false);
}
}
if (!aAttributes) {
return newContent;
}
SetHTMLElementAttributes(newContent, aName, aAttributes);
} else {
nsCOMPtr<dom::Element> newElement;
if (isCustomElement) {
NS_NewHTMLElement(getter_AddRefs(newElement), nodeInfo.forget(),
aFromParser, (isValue.IsEmpty() ? nullptr : &isValue),
definition);
} else {
newElement = aCreator(nodeInfo.forget(), aFromParser);
}
MOZ_ASSERT(newElement, "Element creation created null pointer.");
newContent = newElement;
aBuilder->HoldElement(newElement.forget());
if (MOZ_UNLIKELY(aName == nsHtml5Atoms::style || aName == nsHtml5Atoms::link)) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(newContent));
if (ssle) {
ssle->InitStyleLinkElement(false);
ssle->SetEnableUpdates(false);
}
} else if (MOZ_UNLIKELY(isKeygen)) {
// Adapted from CNavDTD
nsresult rv;
nsCOMPtr<nsIFormProcessor> theFormProcessor =
do_GetService(kFormProcessorCID, &rv);
if (NS_FAILED(rv)) {
return newContent;
}
nsTArray<nsString> theContent;
nsAutoString theAttribute;
(void) theFormProcessor->ProvideContent(NS_LITERAL_STRING("select"),
theContent,
theAttribute);
newContent->SetAttr(kNameSpaceID_None,
nsGkAtoms::moztype,
nullptr,
theAttribute,
false);
RefPtr<dom::NodeInfo> optionNodeInfo = aNodeInfoManager->GetNodeInfo(
nsHtml5Atoms::option, nullptr, kNameSpaceID_XHTML, nsIDOMNode::ELEMENT_NODE);
for (uint32_t i = 0; i < theContent.Length(); ++i) {
RefPtr<dom::NodeInfo> ni = optionNodeInfo;
nsCOMPtr<dom::Element> optionElt =
NS_NewHTMLOptionElement(ni.forget(), aFromParser);
RefPtr<nsTextNode> optionText = new nsTextNode(aNodeInfoManager);
(void) optionText->SetText(theContent[i], false);
optionElt->AppendChildTo(optionText, false);
newContent->AppendChildTo(optionElt, false);
}
newContent->DoneAddingChildren(false);
}
if (!aAttributes) {
return newContent;
}
SetHTMLElementAttributes(newContent, aName, aAttributes);
}
return newContent;
}
nsIContent*
nsHtml5TreeOperation::CreateSVGElement(
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
mozilla::dom::FromParser aFromParser,
nsNodeInfoManager* aNodeInfoManager,
nsHtml5DocumentBuilder* aBuilder,
mozilla::dom::SVGContentCreatorFunction aCreator)
{
nsCOMPtr<nsIContent> newElement;
RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
aName, nullptr, kNameSpaceID_SVG, nsIDOMNode::ELEMENT_NODE);
MOZ_ASSERT(nodeInfo, "Got null nodeinfo.");
mozilla::DebugOnly<nsresult> rv =
aCreator(getter_AddRefs(newElement), nodeInfo.forget(), aFromParser);
MOZ_ASSERT(NS_SUCCEEDED(rv) && newElement);
dom::Element* newContent = newElement->AsElement();
aBuilder->HoldElement(newElement.forget());
if (MOZ_UNLIKELY(aName == nsHtml5Atoms::style || aName == nsHtml5Atoms::link)) {
if (MOZ_UNLIKELY(aName == nsHtml5Atoms::style)) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(newContent));
if (ssle) {
ssle->InitStyleLinkElement(false);
ssle->SetEnableUpdates(false);
}
} else if (MOZ_UNLIKELY(isKeygen)) {
// Adapted from CNavDTD
nsresult rv;
nsCOMPtr<nsIFormProcessor> theFormProcessor =
do_GetService(kFormProcessorCID, &rv);
if (NS_FAILED(rv)) {
return newContent;
}
nsTArray<nsString> theContent;
nsAutoString theAttribute;
(void) theFormProcessor->ProvideContent(NS_LITERAL_STRING("select"),
theContent,
theAttribute);
newContent->SetAttr(kNameSpaceID_None,
nsGkAtoms::moztype,
nullptr,
theAttribute,
false);
RefPtr<dom::NodeInfo> optionNodeInfo =
aNodeInfoManager->GetNodeInfo(nsHtml5Atoms::option,
nullptr,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
for (uint32_t i = 0; i < theContent.Length(); ++i) {
nsCOMPtr<dom::Element> optionElt;
RefPtr<dom::NodeInfo> ni = optionNodeInfo;
NS_NewElement(getter_AddRefs(optionElt),
ni.forget(),
aFromParser);
RefPtr<nsTextNode> optionText = new nsTextNode(aNodeInfoManager);
(void) optionText->SetText(theContent[i], false);
optionElt->AppendChildTo(optionText, false);
newContent->AppendChildTo(optionElt, false);
// XXXsmaug Shouldn't we call this after adding all the child nodes.
newContent->DoneAddingChildren(false);
}
}
if (!aAttributes) {
@ -419,30 +589,45 @@ nsHtml5TreeOperation::CreateElement(int32_t aNs,
nsString value; // Not Auto, because using it to hold nsStringBuffer*
aAttributes->getValueNoBoundsCheck(i).ToString(value);
if (aNs == kNameSpaceID_XHTML &&
nsHtml5Atoms::a == aName &&
nsHtml5Atoms::name == localName) {
// This is an HTML5-incompliant Geckoism.
// Remove when fixing bug 582361
NS_ConvertUTF16toUTF8 cname(value);
NS_ConvertUTF8toUTF16 uv(nsUnescape(cname.BeginWriting()));
newContent->SetAttr(nsuri,
localName,
prefix,
uv,
false);
} else {
newContent->SetAttr(nsuri,
localName,
prefix,
value,
false);
newContent->SetAttr(nsuri, localName, prefix, value, false);
}
return newContent;
}
// Custom element setup may be needed if there is an "is" attribute.
if (kNameSpaceID_None == nsuri && !prefix && nsGkAtoms::is == localName) {
nsContentUtils::SetupCustomElement(newContent, &value);
}
}
nsIContent*
nsHtml5TreeOperation::CreateMathMLElement(nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
nsNodeInfoManager* aNodeInfoManager,
nsHtml5DocumentBuilder* aBuilder)
{
nsCOMPtr<dom::Element> newElement;
RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
aName, nullptr, kNameSpaceID_MathML, nsIDOMNode::ELEMENT_NODE);
NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
mozilla::DebugOnly<nsresult> rv =
NS_NewMathMLElement(getter_AddRefs(newElement), nodeInfo.forget());
MOZ_ASSERT(NS_SUCCEEDED(rv) && newElement);
dom::Element* newContent = newElement;
aBuilder->HoldElement(newElement.forget());
if (!aAttributes) {
return newContent;
}
int32_t len = aAttributes->getLength();
for (int32_t i = 0; i < len; i++) {
// prefix doesn't need regetting. it is always null or a static atom
// local name is never null
nsCOMPtr<nsIAtom> localName =
Reget(aAttributes->getLocalNameNoBoundsCheck(i));
nsCOMPtr<nsIAtom> prefix = aAttributes->getPrefixNoBoundsCheck(i);
int32_t nsuri = aAttributes->getURINoBoundsCheck(i);
nsString value; // Not Auto, because using it to hold nsStringBuffer*
aAttributes->getValueNoBoundsCheck(i).ToString(value);
newContent->SetAttr(nsuri, localName, prefix, value, false);
}
return newContent;
}
@ -673,10 +858,56 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
aBuilder->SetDocumentMode(mOne.mode);
return NS_OK;
}
case eTreeOpCreateElementNetwork:
case eTreeOpCreateElementNotNetwork: {
case eTreeOpCreateHTMLElementNetwork:
case eTreeOpCreateHTMLElementNotNetwork: {
nsIContent** target = mOne.node;
mozilla::dom::HTMLContentCreatorFunction creator = mFour.htmlCreator;
nsCOMPtr<nsIAtom> name = Reget(mTwo.atom);
nsHtml5HtmlAttributes* attributes = mThree.attributes;
nsIContent* intendedParent = mFive.node ? *(mFive.node) : nullptr;
// intendedParent == nullptr is a special case where the
// intended parent is the document.
nsNodeInfoManager* nodeInfoManager =
intendedParent ? intendedParent->OwnerDoc()->NodeInfoManager()
: aBuilder->GetNodeInfoManager();
*target = CreateHTMLElement(name,
attributes,
mOpCode == eTreeOpCreateHTMLElementNetwork
? dom::FROM_PARSER_NETWORK
: dom::FROM_PARSER_DOCUMENT_WRITE,
nodeInfoManager,
aBuilder,
creator);
return NS_OK;
}
case eTreeOpCreateSVGElementNetwork:
case eTreeOpCreateSVGElementNotNetwork: {
nsIContent** target = mOne.node;
mozilla::dom::SVGContentCreatorFunction creator = mFour.svgCreator;
nsCOMPtr<nsIAtom> name = Reget(mTwo.atom);
nsHtml5HtmlAttributes* attributes = mThree.attributes;
nsIContent* intendedParent = mFive.node ? *(mFive.node) : nullptr;
// intendedParent == nullptr is a special case where the
// intended parent is the document.
nsNodeInfoManager* nodeInfoManager =
intendedParent ? intendedParent->OwnerDoc()->NodeInfoManager()
: aBuilder->GetNodeInfoManager();
*target = CreateSVGElement(name,
attributes,
mOpCode == eTreeOpCreateSVGElementNetwork
? dom::FROM_PARSER_NETWORK
: dom::FROM_PARSER_DOCUMENT_WRITE,
nodeInfoManager,
aBuilder,
creator);
return NS_OK;
}
case eTreeOpCreateMathMLElement: {
nsIContent** target = mOne.node;
int32_t ns = mFour.integer;
nsCOMPtr<nsIAtom> name = Reget(mTwo.atom);
nsHtml5HtmlAttributes* attributes = mThree.attributes;
nsIContent* intendedParent = mFive.node ? *(mFive.node) : nullptr;
@ -687,14 +918,8 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
intendedParent->OwnerDoc()->NodeInfoManager() :
aBuilder->GetNodeInfoManager();
*target = CreateElement(ns,
name,
attributes,
mOpCode == eTreeOpCreateElementNetwork ?
dom::FROM_PARSER_NETWORK :
dom::FROM_PARSER_DOCUMENT_WRITE,
nodeInfoManager,
aBuilder);
*target =
CreateMathMLElement(name, attributes, nodeInfoManager, aBuilder);
return NS_OK;
}
case eTreeOpSetFormElement: {

View file

@ -14,7 +14,8 @@ class nsIContent;
class nsHtml5TreeOpExecutor;
class nsHtml5DocumentBuilder;
enum eHtml5TreeOperation {
enum eHtml5TreeOperation
{
eTreeOpUninitialized,
// main HTML5 ops
eTreeOpAppend,
@ -24,8 +25,11 @@ enum eHtml5TreeOperation {
eTreeOpAppendToDocument,
eTreeOpAddAttributes,
eTreeOpDocumentMode,
eTreeOpCreateElementNetwork,
eTreeOpCreateElementNotNetwork,
eTreeOpCreateHTMLElementNetwork,
eTreeOpCreateHTMLElementNotNetwork,
eTreeOpCreateSVGElementNetwork,
eTreeOpCreateSVGElementNotNetwork,
eTreeOpCreateMathMLElement,
eTreeOpSetFormElement,
eTreeOpAppendText,
eTreeOpAppendIsindexPrompt,
@ -139,16 +143,34 @@ class nsHtml5TreeOperation {
nsIContent* aTable,
nsHtml5DocumentBuilder* aBuilder);
static void SetHTMLElementAttributes(mozilla::dom::Element* aElement,
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes);
static nsresult AddAttributes(nsIContent* aNode,
nsHtml5HtmlAttributes* aAttributes,
nsHtml5DocumentBuilder* aBuilder);
static nsIContent* CreateElement(int32_t aNs,
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
mozilla::dom::FromParser aFromParser,
nsNodeInfoManager* aNodeInfoManager,
nsHtml5DocumentBuilder* aBuilder);
static nsIContent* CreateHTMLElement(
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
mozilla::dom::FromParser aFromParser,
nsNodeInfoManager* aNodeInfoManager,
nsHtml5DocumentBuilder* aBuilder,
mozilla::dom::HTMLContentCreatorFunction aCreator);
static nsIContent* CreateSVGElement(
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
mozilla::dom::FromParser aFromParser,
nsNodeInfoManager* aNodeInfoManager,
nsHtml5DocumentBuilder* aBuilder,
mozilla::dom::SVGContentCreatorFunction aCreator);
static nsIContent* CreateMathMLElement(nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
nsNodeInfoManager* aNodeInfoManager,
nsHtml5DocumentBuilder* aBuilder);
static void SetFormElement(nsIContent* aNode, nsIContent* aParent);
@ -284,22 +306,31 @@ class nsHtml5TreeOperation {
mOne.node = static_cast<nsIContent**>(aNode);
mTwo.state = nullptr;
}
inline void Init(int32_t aNamespace,
nsIAtom* aName,
inline void Init(int32_t aNamespace,
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
nsIContentHandle* aTarget,
nsIContentHandle* aIntendedParent,
bool aFromNetwork)
bool aFromNetwork,
nsHtml5ContentCreatorFunction aCreator)
{
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aName, "Initialized tree op with null name.");
NS_PRECONDITION(aTarget, "Initialized tree op with null target node.");
mOpCode = aFromNetwork ?
eTreeOpCreateElementNetwork :
eTreeOpCreateElementNotNetwork;
mFour.integer = aNamespace;
if (aNamespace == kNameSpaceID_XHTML) {
mOpCode = aFromNetwork ? eTreeOpCreateHTMLElementNetwork
: eTreeOpCreateHTMLElementNotNetwork;
mFour.htmlCreator = aCreator.html;
} else if (aNamespace == kNameSpaceID_SVG) {
mOpCode = aFromNetwork ? eTreeOpCreateSVGElementNetwork
: eTreeOpCreateSVGElementNotNetwork;
mFour.svgCreator = aCreator.svg;
} else {
MOZ_ASSERT(aNamespace == kNameSpaceID_MathML);
mOpCode = eTreeOpCreateMathMLElement;
}
mFive.node = static_cast<nsIContent**>(aIntendedParent);
mOne.node = static_cast<nsIContent**>(aTarget);
mTwo.atom = aName;
@ -507,6 +538,8 @@ class nsHtml5TreeOperation {
nsAHtml5TreeBuilderState* state;
int32_t integer;
nsresult result;
mozilla::dom::HTMLContentCreatorFunction htmlCreator;
mozilla::dom::SVGContentCreatorFunction svgCreator;
} mOne, mTwo, mThree, mFour, mFive;
};

View file

@ -43,13 +43,14 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
#include "nsHtml5Portability.h"
#include "nsHtml5ContentCreatorFunction.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5MetaScanner.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5StackNode.h"
#include "nsHtml5StateSnapshot.h"
#include "nsHtml5Portability.h"

View file

@ -44,15 +44,16 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
#include "nsHtml5Portability.h"
#include "nsHtml5ContentCreatorFunction.h"
class nsHtml5StreamParser;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5MetaScanner;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5StateSnapshot;
class nsHtml5Portability;
@ -78,7 +79,5 @@ class nsHtml5UTF16Buffer
#include "nsHtml5UTF16BufferHSupplement.h"
};
#endif