зеркало из https://github.com/mozilla/pjs.git
Bug 539434 follow-up - Sync the Java sources of the HTML5 parser with the htmlparser repository. rs=sicking. NPOTB.
--HG-- extra : rebase_source : 6ff1b377ab4663bc7a34c805da92a5d8e3adaed1
This commit is contained in:
Родитель
b8ce41f8c4
Коммит
14f4d6b161
|
@ -31,18 +31,27 @@ import nu.validator.htmlparser.annotation.NsUri;
|
|||
import nu.validator.htmlparser.annotation.Prefix;
|
||||
import nu.validator.htmlparser.annotation.QName;
|
||||
import nu.validator.htmlparser.annotation.Virtual;
|
||||
import nu.validator.htmlparser.common.Interner;
|
||||
|
||||
public final class AttributeName
|
||||
// Uncomment to regenerate
|
||||
// implements Comparable<AttributeName>
|
||||
// implements Comparable<AttributeName>
|
||||
{
|
||||
|
||||
private static final @NoLength @NsUri String[] ALL_NO_NS = { "", "", "",
|
||||
/**
|
||||
* An array representing no namespace regardless of namespace mode (HTML,
|
||||
* SVG, MathML, lang-mapping HTML) used.
|
||||
*/
|
||||
static final @NoLength @NsUri String[] ALL_NO_NS = { "", "", "",
|
||||
// [NOCPP[
|
||||
""
|
||||
// ]NOCPP]
|
||||
};
|
||||
|
||||
/**
|
||||
* An array that has no namespace for the HTML mode but the XMLNS namespace
|
||||
* for the SVG and MathML modes.
|
||||
*/
|
||||
private static final @NoLength @NsUri String[] XMLNS_NS = { "",
|
||||
"http://www.w3.org/2000/xmlns/", "http://www.w3.org/2000/xmlns/",
|
||||
// [NOCPP[
|
||||
|
@ -50,6 +59,10 @@ public final class AttributeName
|
|||
// ]NOCPP]
|
||||
};
|
||||
|
||||
/**
|
||||
* An array that has no namespace for the HTML mode but the XML namespace
|
||||
* for the SVG and MathML modes.
|
||||
*/
|
||||
private static final @NoLength @NsUri String[] XML_NS = { "",
|
||||
"http://www.w3.org/XML/1998/namespace",
|
||||
"http://www.w3.org/XML/1998/namespace",
|
||||
|
@ -58,6 +71,10 @@ public final class AttributeName
|
|||
// ]NOCPP]
|
||||
};
|
||||
|
||||
/**
|
||||
* An array that has no namespace for the HTML mode but the XLink namespace
|
||||
* for the SVG and MathML modes.
|
||||
*/
|
||||
private static final @NoLength @NsUri String[] XLINK_NS = { "",
|
||||
"http://www.w3.org/1999/xlink", "http://www.w3.org/1999/xlink",
|
||||
// [NOCPP[
|
||||
|
@ -66,18 +83,28 @@ public final class AttributeName
|
|||
};
|
||||
|
||||
// [NOCPP[
|
||||
/**
|
||||
* An array that has no namespace for the HTML, SVG and MathML modes but has
|
||||
* the XML namespace for the lang-mapping HTML mode.
|
||||
*/
|
||||
private static final @NoLength @NsUri String[] LANG_NS = { "", "", "",
|
||||
"http://www.w3.org/XML/1998/namespace" };
|
||||
|
||||
// ]NOCPP]
|
||||
|
||||
private static final @NoLength @Prefix String[] ALL_NO_PREFIX = { null,
|
||||
null, null,
|
||||
// [NOCPP[
|
||||
/**
|
||||
* An array for no prefixes in any mode.
|
||||
*/
|
||||
static final @NoLength @Prefix String[] ALL_NO_PREFIX = { null, null, null,
|
||||
// [NOCPP[
|
||||
null
|
||||
// ]NOCPP]
|
||||
};
|
||||
|
||||
/**
|
||||
* An array for no prefixe in the HTML mode and the <code>xmlns</code>
|
||||
* prefix in the SVG and MathML modes.
|
||||
*/
|
||||
private static final @NoLength @Prefix String[] XMLNS_PREFIX = { null,
|
||||
"xmlns", "xmlns",
|
||||
// [NOCPP[
|
||||
|
@ -85,6 +112,10 @@ public final class AttributeName
|
|||
// ]NOCPP]
|
||||
};
|
||||
|
||||
/**
|
||||
* An array for no prefixe in the HTML mode and the <code>xlink</code>
|
||||
* prefix in the SVG and MathML modes.
|
||||
*/
|
||||
private static final @NoLength @Prefix String[] XLINK_PREFIX = { null,
|
||||
"xlink", "xlink",
|
||||
// [NOCPP[
|
||||
|
@ -92,6 +123,10 @@ public final class AttributeName
|
|||
// ]NOCPP]
|
||||
};
|
||||
|
||||
/**
|
||||
* An array for no prefixe in the HTML mode and the <code>xml</code> prefix
|
||||
* in the SVG and MathML modes.
|
||||
*/
|
||||
private static final @NoLength @Prefix String[] XML_PREFIX = { null, "xml",
|
||||
"xml",
|
||||
// [NOCPP[
|
||||
|
@ -122,6 +157,16 @@ public final class AttributeName
|
|||
|
||||
// ]NOCPP]
|
||||
|
||||
/**
|
||||
* An initialization helper for having a one name in the SVG mode and
|
||||
* another name in the other modes.
|
||||
*
|
||||
* @param name
|
||||
* the name for the non-SVG modes
|
||||
* @param camel
|
||||
* the name for the SVG mode
|
||||
* @return the initialized name array
|
||||
*/
|
||||
private static @NoLength @Local String[] SVG_DIFFERENT(@Local String name,
|
||||
@Local String camel) {
|
||||
@NoLength @Local String[] arr = new String[4];
|
||||
|
@ -134,6 +179,16 @@ public final class AttributeName
|
|||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* An initialization helper for having a one name in the MathML mode and
|
||||
* another name in the other modes.
|
||||
*
|
||||
* @param name
|
||||
* the name for the non-MathML modes
|
||||
* @param camel
|
||||
* the name for the MathML mode
|
||||
* @return the initialized name array
|
||||
*/
|
||||
private static @NoLength @Local String[] MATH_DIFFERENT(@Local String name,
|
||||
@Local String camel) {
|
||||
@NoLength @Local String[] arr = new String[4];
|
||||
|
@ -146,6 +201,16 @@ public final class AttributeName
|
|||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* An initialization helper for having a different local name in the HTML
|
||||
* mode and the SVG and MathML modes.
|
||||
*
|
||||
* @param name
|
||||
* the name for the HTML mode
|
||||
* @param suffix
|
||||
* the name for the SVG and MathML modes
|
||||
* @return the initialized name array
|
||||
*/
|
||||
private static @NoLength @Local String[] COLONIFIED_LOCAL(
|
||||
@Local String name, @Local String suffix) {
|
||||
@NoLength @Local String[] arr = new String[4];
|
||||
|
@ -158,7 +223,14 @@ public final class AttributeName
|
|||
return arr;
|
||||
}
|
||||
|
||||
private static @NoLength @Local String[] SAME_LOCAL(@Local String name) {
|
||||
/**
|
||||
* An initialization helper for having the same local name in all modes.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @return the initialized name array
|
||||
*/
|
||||
static @NoLength @Local String[] SAME_LOCAL(@Local String name) {
|
||||
@NoLength @Local String[] arr = new String[4];
|
||||
arr[0] = name;
|
||||
arr[1] = name;
|
||||
|
@ -178,23 +250,28 @@ public final class AttributeName
|
|||
* HtmlAttributes and released upon clearing or destroying that object.
|
||||
*
|
||||
* @param buf
|
||||
* the buffer
|
||||
* @param offset
|
||||
* ignored
|
||||
* @param length
|
||||
* length of data
|
||||
* @param checkNcName
|
||||
* @return
|
||||
* whether to check ncnameness
|
||||
* @return an <code>AttributeName</code> corresponding to the argument data
|
||||
*/
|
||||
static AttributeName nameByBuffer(@NoLength char[] buf, int offset,
|
||||
int length
|
||||
// [NOCPP[
|
||||
, boolean checkNcName
|
||||
// ]NOCPP]
|
||||
) {
|
||||
// ]NOCPP]
|
||||
, Interner interner) {
|
||||
// XXX deal with offset
|
||||
int hash = AttributeName.bufToHash(buf, length);
|
||||
int index = Arrays.binarySearch(AttributeName.ATTRIBUTE_HASHES, hash);
|
||||
if (index < 0) {
|
||||
return AttributeName.createAttributeName(
|
||||
Portability.newLocalNameFromBuffer(buf, offset, length)
|
||||
Portability.newLocalNameFromBuffer(buf, offset, length,
|
||||
interner)
|
||||
// [NOCPP[
|
||||
, checkNcName
|
||||
// ]NOCPP]
|
||||
|
@ -204,7 +281,8 @@ public final class AttributeName
|
|||
@Local String name = attributeName.getLocal(AttributeName.HTML);
|
||||
if (!Portability.localEqualsBuffer(name, buf, offset, length)) {
|
||||
return AttributeName.createAttributeName(
|
||||
Portability.newLocalNameFromBuffer(buf, offset, length)
|
||||
Portability.newLocalNameFromBuffer(buf, offset, length,
|
||||
interner)
|
||||
// [NOCPP[
|
||||
, checkNcName
|
||||
// ]NOCPP]
|
||||
|
@ -238,42 +316,83 @@ public final class AttributeName
|
|||
return hash ^ hash2;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mode value for HTML.
|
||||
*/
|
||||
public static final int HTML = 0;
|
||||
|
||||
/**
|
||||
* The mode value for MathML.
|
||||
*/
|
||||
public static final int MATHML = 1;
|
||||
|
||||
/**
|
||||
* The mode value for SVG.
|
||||
*/
|
||||
public static final int SVG = 2;
|
||||
|
||||
// [NOCPP[
|
||||
|
||||
/**
|
||||
* The mode value for lang-mapping HTML.
|
||||
*/
|
||||
public static final int HTML_LANG = 3;
|
||||
|
||||
/**
|
||||
* The XML data type of this attribute.
|
||||
*/
|
||||
private final @IdType String type;
|
||||
|
||||
// ]NOCPP]
|
||||
|
||||
/**
|
||||
* The namespaces indexable by mode.
|
||||
*/
|
||||
private final @NsUri @NoLength String[] uri;
|
||||
|
||||
/**
|
||||
* The local names indexable by mode.
|
||||
*/
|
||||
private final @Local @NoLength String[] local;
|
||||
|
||||
/**
|
||||
* The prefixes indexably by mode.
|
||||
*/
|
||||
private final @Prefix @NoLength String[] prefix;
|
||||
|
||||
// [NOCPP[
|
||||
|
||||
/**
|
||||
* The qnames indexable by mode.
|
||||
*/
|
||||
private final @QName @NoLength String[] qName;
|
||||
|
||||
// XXX convert to bitfield
|
||||
/**
|
||||
* Data on which names are ncnames indexable by mode.
|
||||
*/
|
||||
private final @NoLength boolean[] ncname;
|
||||
|
||||
/**
|
||||
* This in an xmlns attribute.
|
||||
*/
|
||||
private final boolean xmlns;
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* The run-time constructor.
|
||||
*
|
||||
* @param uri
|
||||
* the namespace
|
||||
* @param local
|
||||
* @param name
|
||||
* the local name
|
||||
* @param prefix
|
||||
* the prefix
|
||||
* @param ncname
|
||||
* the ncnameness
|
||||
* @param xmlns
|
||||
* whether this is an xmlns attribute
|
||||
* @param type
|
||||
* the XML datatype
|
||||
*/
|
||||
private AttributeName(@NsUri @NoLength String[] uri,
|
||||
@Local @NoLength String[] local, @Prefix @NoLength String[] prefix,
|
||||
|
@ -290,6 +409,20 @@ public final class AttributeName
|
|||
|
||||
// ]NOCPP]
|
||||
|
||||
/**
|
||||
* The startup-time constructor.
|
||||
*
|
||||
* @param uri
|
||||
* the namespace
|
||||
* @param local
|
||||
* the local name
|
||||
* @param prefix
|
||||
* the prefix
|
||||
* @param ncname
|
||||
* the ncnameness
|
||||
* @param xmlns
|
||||
* whether this is an xmlns attribute
|
||||
*/
|
||||
protected AttributeName(@NsUri @NoLength String[] uri,
|
||||
@Local @NoLength String[] local, @Prefix @NoLength String[] prefix
|
||||
// [NOCPP[
|
||||
|
@ -309,6 +442,15 @@ public final class AttributeName
|
|||
// ]NOCPP]
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an <code>AttributeName</code> for a local name.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param checkNcName
|
||||
* whether to check ncnameness
|
||||
* @return an <code>AttributeName</code>
|
||||
*/
|
||||
private static AttributeName createAttributeName(@Local String name
|
||||
// [NOCPP[
|
||||
, boolean checkNcName
|
||||
|
@ -334,11 +476,17 @@ public final class AttributeName
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes runtime-allocated instances in C++.
|
||||
*/
|
||||
@Virtual void release() {
|
||||
// No-op in Java.
|
||||
// Implement as |delete this;| in subclass.
|
||||
}
|
||||
|
||||
/**
|
||||
* The C++ destructor.
|
||||
*/
|
||||
@SuppressWarnings("unused") private void destructor() {
|
||||
Portability.releaseLocal(local[0]); // this must be a no-op for static
|
||||
// locals
|
||||
|
@ -347,6 +495,18 @@ public final class AttributeName
|
|||
Portability.deleteArray(local);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones the attribute using an interner. Returns <code>this</code> in Java
|
||||
* and for non-dynamic instances in C++.
|
||||
*
|
||||
* @param interner
|
||||
* an interner
|
||||
* @return a clone
|
||||
*/
|
||||
@Virtual public AttributeName cloneAttributeName(Interner interner) {
|
||||
return this;
|
||||
}
|
||||
|
||||
// [NOCPP[
|
||||
static AttributeName create(@Local String name) {
|
||||
return new AttributeName(AttributeName.ALL_NO_NS,
|
||||
|
@ -440,158 +600,158 @@ public final class AttributeName
|
|||
|
||||
// START CODE ONLY USED FOR GENERATING CODE uncomment to regenerate
|
||||
|
||||
// /**
|
||||
// * @see java.lang.Object#toString()
|
||||
// */
|
||||
// @Override public String toString() {
|
||||
// return "(" + formatNs() + ", " + formatLocal() + ", " + formatPrefix()
|
||||
// + ", " + formatNcname() + ", " + (xmlns ? "true" : "false")
|
||||
// + ("ID" == type ? ", \"ID\"" : "") + ")";
|
||||
// }
|
||||
//
|
||||
// public int compareTo(AttributeName other) {
|
||||
// int thisHash = this.hash();
|
||||
// int otherHash = other.hash();
|
||||
// if (thisHash < otherHash) {
|
||||
// return -1;
|
||||
// } else if (thisHash == otherHash) {
|
||||
// return 0;
|
||||
// } else {
|
||||
// return 1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String formatPrefix() {
|
||||
// if (prefix[0] == null && prefix[1] == null && prefix[2] == null
|
||||
// && prefix[3] == null) {
|
||||
// return "ALL_NO_PREFIX";
|
||||
// } else if (prefix[0] == null && prefix[1] == prefix[2]
|
||||
// && prefix[3] == null) {
|
||||
// if ("xmlns".equals(prefix[1])) {
|
||||
// return "XMLNS_PREFIX";
|
||||
// } else if ("xml".equals(prefix[1])) {
|
||||
// return "XML_PREFIX";
|
||||
// } else if ("xlink".equals(prefix[1])) {
|
||||
// return "XLINK_PREFIX";
|
||||
// } else {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
// } else if (prefix[0] == null && prefix[1] == null && prefix[2] == null
|
||||
// && prefix[3] == "xml") {
|
||||
// return "LANG_PREFIX";
|
||||
// } else {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String formatLocal() {
|
||||
// if (local[0] == local[1] && local[0] == local[3]
|
||||
// && local[0] != local[2]) {
|
||||
// return "SVG_DIFFERENT(\"" + local[0] + "\", \"" + local[2] + "\")";
|
||||
// }
|
||||
// if (local[0] == local[2] && local[0] == local[3]
|
||||
// && local[0] != local[1]) {
|
||||
// return "MATH_DIFFERENT(\"" + local[0] + "\", \"" + local[1] + "\")";
|
||||
// }
|
||||
// if (local[0] == local[3] && local[1] == local[2]
|
||||
// && local[0] != local[1]) {
|
||||
// return "COLONIFIED_LOCAL(\"" + local[0] + "\", \"" + local[1]
|
||||
// + "\")";
|
||||
// }
|
||||
// for (int i = 1; i < local.length; i++) {
|
||||
// if (local[0] != local[i]) {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
// }
|
||||
// return "SAME_LOCAL(\"" + local[0] + "\")";
|
||||
// }
|
||||
//
|
||||
// private String formatNs() {
|
||||
// if (uri[0] == "" && uri[1] == "" && uri[2] == "" && uri[3] == "") {
|
||||
// return "ALL_NO_NS";
|
||||
// } else if (uri[0] == "" && uri[1] == uri[2] && uri[3] == "") {
|
||||
// if ("http://www.w3.org/2000/xmlns/".equals(uri[1])) {
|
||||
// return "XMLNS_NS";
|
||||
// } else if ("http://www.w3.org/XML/1998/namespace".equals(uri[1])) {
|
||||
// return "XML_NS";
|
||||
// } else if ("http://www.w3.org/1999/xlink".equals(uri[1])) {
|
||||
// return "XLINK_NS";
|
||||
// } else {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
// } else if (uri[0] == "" && uri[1] == "" && uri[2] == ""
|
||||
// && uri[3] == "http://www.w3.org/XML/1998/namespace") {
|
||||
// return "LANG_NS";
|
||||
// } else {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String formatNcname() {
|
||||
// for (int i = 0; i < ncname.length; i++) {
|
||||
// if (!ncname[i]) {
|
||||
// return "new boolean[]{" + ncname[0] + ", " + ncname[1] + ", "
|
||||
// + ncname[2] + ", " + ncname[3] + "}";
|
||||
// }
|
||||
// }
|
||||
// return "ALL_NCNAME";
|
||||
// }
|
||||
//
|
||||
// private String constName() {
|
||||
// String name = getLocal(HTML);
|
||||
// char[] buf = new char[name.length()];
|
||||
// for (int i = 0; i < name.length(); i++) {
|
||||
// char c = name.charAt(i);
|
||||
// if (c == '-' || c == ':') {
|
||||
// buf[i] = '_';
|
||||
// } else if (c >= 'a' && c <= 'z') {
|
||||
// buf[i] = (char) (c - 0x20);
|
||||
// } else {
|
||||
// buf[i] = c;
|
||||
// }
|
||||
// }
|
||||
// return new String(buf);
|
||||
// }
|
||||
//
|
||||
// private int hash() {
|
||||
// String name = getLocal(HTML);
|
||||
// return bufToHash(name.toCharArray(), name.length());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Regenerate self
|
||||
// *
|
||||
// * @param args
|
||||
// */
|
||||
// public static void main(String[] args) {
|
||||
// Arrays.sort(ATTRIBUTE_NAMES);
|
||||
// for (int i = 1; i < ATTRIBUTE_NAMES.length; i++) {
|
||||
// if (ATTRIBUTE_NAMES[i].hash() == ATTRIBUTE_NAMES[i - 1].hash()) {
|
||||
// System.err.println("Hash collision: "
|
||||
// + ATTRIBUTE_NAMES[i].getLocal(HTML) + ", "
|
||||
// + ATTRIBUTE_NAMES[i - 1].getLocal(HTML));
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// for (int i = 0; i < ATTRIBUTE_NAMES.length; i++) {
|
||||
// AttributeName att = ATTRIBUTE_NAMES[i];
|
||||
// System.out.println("public static final AttributeName "
|
||||
// + att.constName() + " = new AttributeName" + att.toString()
|
||||
// + ";");
|
||||
// }
|
||||
// System.out.println("private final static @NoLength AttributeName[] ATTRIBUTE_NAMES = {");
|
||||
// for (int i = 0; i < ATTRIBUTE_NAMES.length; i++) {
|
||||
// AttributeName att = ATTRIBUTE_NAMES[i];
|
||||
// System.out.println(att.constName() + ",");
|
||||
// }
|
||||
// System.out.println("};");
|
||||
// System.out.println("private final static int[] ATTRIBUTE_HASHES = {");
|
||||
// for (int i = 0; i < ATTRIBUTE_NAMES.length; i++) {
|
||||
// AttributeName att = ATTRIBUTE_NAMES[i];
|
||||
// System.out.println(Integer.toString(att.hash()) + ",");
|
||||
// }
|
||||
// System.out.println("};");
|
||||
// }
|
||||
// /**
|
||||
// * @see java.lang.Object#toString()
|
||||
// */
|
||||
// @Override public String toString() {
|
||||
// return "(" + formatNs() + ", " + formatLocal() + ", " + formatPrefix()
|
||||
// + ", " + formatNcname() + ", " + (xmlns ? "true" : "false")
|
||||
// + ("ID" == type ? ", \"ID\"" : "") + ")";
|
||||
// }
|
||||
//
|
||||
// public int compareTo(AttributeName other) {
|
||||
// int thisHash = this.hash();
|
||||
// int otherHash = other.hash();
|
||||
// if (thisHash < otherHash) {
|
||||
// return -1;
|
||||
// } else if (thisHash == otherHash) {
|
||||
// return 0;
|
||||
// } else {
|
||||
// return 1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String formatPrefix() {
|
||||
// if (prefix[0] == null && prefix[1] == null && prefix[2] == null
|
||||
// && prefix[3] == null) {
|
||||
// return "ALL_NO_PREFIX";
|
||||
// } else if (prefix[0] == null && prefix[1] == prefix[2]
|
||||
// && prefix[3] == null) {
|
||||
// if ("xmlns".equals(prefix[1])) {
|
||||
// return "XMLNS_PREFIX";
|
||||
// } else if ("xml".equals(prefix[1])) {
|
||||
// return "XML_PREFIX";
|
||||
// } else if ("xlink".equals(prefix[1])) {
|
||||
// return "XLINK_PREFIX";
|
||||
// } else {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
// } else if (prefix[0] == null && prefix[1] == null && prefix[2] == null
|
||||
// && prefix[3] == "xml") {
|
||||
// return "LANG_PREFIX";
|
||||
// } else {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String formatLocal() {
|
||||
// if (local[0] == local[1] && local[0] == local[3]
|
||||
// && local[0] != local[2]) {
|
||||
// return "SVG_DIFFERENT(\"" + local[0] + "\", \"" + local[2] + "\")";
|
||||
// }
|
||||
// if (local[0] == local[2] && local[0] == local[3]
|
||||
// && local[0] != local[1]) {
|
||||
// return "MATH_DIFFERENT(\"" + local[0] + "\", \"" + local[1] + "\")";
|
||||
// }
|
||||
// if (local[0] == local[3] && local[1] == local[2]
|
||||
// && local[0] != local[1]) {
|
||||
// return "COLONIFIED_LOCAL(\"" + local[0] + "\", \"" + local[1]
|
||||
// + "\")";
|
||||
// }
|
||||
// for (int i = 1; i < local.length; i++) {
|
||||
// if (local[0] != local[i]) {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
// }
|
||||
// return "SAME_LOCAL(\"" + local[0] + "\")";
|
||||
// }
|
||||
//
|
||||
// private String formatNs() {
|
||||
// if (uri[0] == "" && uri[1] == "" && uri[2] == "" && uri[3] == "") {
|
||||
// return "ALL_NO_NS";
|
||||
// } else if (uri[0] == "" && uri[1] == uri[2] && uri[3] == "") {
|
||||
// if ("http://www.w3.org/2000/xmlns/".equals(uri[1])) {
|
||||
// return "XMLNS_NS";
|
||||
// } else if ("http://www.w3.org/XML/1998/namespace".equals(uri[1])) {
|
||||
// return "XML_NS";
|
||||
// } else if ("http://www.w3.org/1999/xlink".equals(uri[1])) {
|
||||
// return "XLINK_NS";
|
||||
// } else {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
// } else if (uri[0] == "" && uri[1] == "" && uri[2] == ""
|
||||
// && uri[3] == "http://www.w3.org/XML/1998/namespace") {
|
||||
// return "LANG_NS";
|
||||
// } else {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String formatNcname() {
|
||||
// for (int i = 0; i < ncname.length; i++) {
|
||||
// if (!ncname[i]) {
|
||||
// return "new boolean[]{" + ncname[0] + ", " + ncname[1] + ", "
|
||||
// + ncname[2] + ", " + ncname[3] + "}";
|
||||
// }
|
||||
// }
|
||||
// return "ALL_NCNAME";
|
||||
// }
|
||||
//
|
||||
// private String constName() {
|
||||
// String name = getLocal(HTML);
|
||||
// char[] buf = new char[name.length()];
|
||||
// for (int i = 0; i < name.length(); i++) {
|
||||
// char c = name.charAt(i);
|
||||
// if (c == '-' || c == ':') {
|
||||
// buf[i] = '_';
|
||||
// } else if (c >= 'a' && c <= 'z') {
|
||||
// buf[i] = (char) (c - 0x20);
|
||||
// } else {
|
||||
// buf[i] = c;
|
||||
// }
|
||||
// }
|
||||
// return new String(buf);
|
||||
// }
|
||||
//
|
||||
// private int hash() {
|
||||
// String name = getLocal(HTML);
|
||||
// return bufToHash(name.toCharArray(), name.length());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Regenerate self
|
||||
// *
|
||||
// * @param args
|
||||
// */
|
||||
// public static void main(String[] args) {
|
||||
// Arrays.sort(ATTRIBUTE_NAMES);
|
||||
// for (int i = 1; i < ATTRIBUTE_NAMES.length; i++) {
|
||||
// if (ATTRIBUTE_NAMES[i].hash() == ATTRIBUTE_NAMES[i - 1].hash()) {
|
||||
// System.err.println("Hash collision: "
|
||||
// + ATTRIBUTE_NAMES[i].getLocal(HTML) + ", "
|
||||
// + ATTRIBUTE_NAMES[i - 1].getLocal(HTML));
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// for (int i = 0; i < ATTRIBUTE_NAMES.length; i++) {
|
||||
// AttributeName att = ATTRIBUTE_NAMES[i];
|
||||
// System.out.println("public static final AttributeName "
|
||||
// + att.constName() + " = new AttributeName" + att.toString()
|
||||
// + ";");
|
||||
// }
|
||||
// System.out.println("private final static @NoLength AttributeName[] ATTRIBUTE_NAMES = {");
|
||||
// for (int i = 0; i < ATTRIBUTE_NAMES.length; i++) {
|
||||
// AttributeName att = ATTRIBUTE_NAMES[i];
|
||||
// System.out.println(att.constName() + ",");
|
||||
// }
|
||||
// System.out.println("};");
|
||||
// System.out.println("private final static int[] ATTRIBUTE_HASHES = {");
|
||||
// for (int i = 0; i < ATTRIBUTE_NAMES.length; i++) {
|
||||
// AttributeName att = ATTRIBUTE_NAMES[i];
|
||||
// System.out.println(Integer.toString(att.hash()) + ",");
|
||||
// }
|
||||
// System.out.println("};");
|
||||
// }
|
||||
|
||||
// START GENERATED CODE
|
||||
public static final AttributeName D = new AttributeName(ALL_NO_NS,
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Arrays;
|
|||
import nu.validator.htmlparser.annotation.Local;
|
||||
import nu.validator.htmlparser.annotation.NoLength;
|
||||
import nu.validator.htmlparser.annotation.Virtual;
|
||||
import nu.validator.htmlparser.common.Interner;
|
||||
|
||||
public final class ElementName
|
||||
// uncomment when regenerating self
|
||||
|
@ -53,17 +54,17 @@ public final class ElementName
|
|||
|
||||
// ]NOCPP]
|
||||
|
||||
static ElementName elementNameByBuffer(char[] buf, int offset, int length) {
|
||||
static ElementName elementNameByBuffer(char[] buf, int offset, int length, Interner interner) {
|
||||
int hash = ElementName.bufToHash(buf, length);
|
||||
int index = Arrays.binarySearch(ElementName.ELEMENT_HASHES, hash);
|
||||
if (index < 0) {
|
||||
return new ElementName(Portability.newLocalNameFromBuffer(buf, offset, length));
|
||||
return new ElementName(Portability.newLocalNameFromBuffer(buf, offset, length, interner));
|
||||
} else {
|
||||
ElementName elementName = ElementName.ELEMENT_NAMES[index];
|
||||
@Local String name = elementName.name;
|
||||
if (!Portability.localEqualsBuffer(name, buf, offset, length)) {
|
||||
return new ElementName(Portability.newLocalNameFromBuffer(buf,
|
||||
offset, length));
|
||||
offset, length, interner));
|
||||
}
|
||||
return elementName;
|
||||
}
|
||||
|
@ -126,6 +127,10 @@ public final class ElementName
|
|||
// for non-static cases the camel case contains the same pointer as a weak reference.
|
||||
}
|
||||
|
||||
@Virtual public ElementName cloneElementName(Interner interner) {
|
||||
return this;
|
||||
}
|
||||
|
||||
// START CODE ONLY USED FOR GENERATING CODE uncomment and run to regenerate
|
||||
|
||||
// /**
|
||||
|
@ -190,6 +195,8 @@ public final class ElementName
|
|||
// return "COL";
|
||||
// case TreeBuilder.COLGROUP:
|
||||
// return "COLGROUP";
|
||||
// case TreeBuilder.FONT:
|
||||
// return "FONT";
|
||||
// case TreeBuilder.FORM:
|
||||
// return "FORM";
|
||||
// case TreeBuilder.FRAME:
|
||||
|
@ -218,6 +225,8 @@ public final class ElementName
|
|||
// return "HR";
|
||||
// case TreeBuilder.HTML:
|
||||
// return "HTML";
|
||||
// case TreeBuilder.KEYGEN:
|
||||
// return "KEYGEN";
|
||||
// case TreeBuilder.NOBR:
|
||||
// return "NOBR";
|
||||
// case TreeBuilder.NOFRAMES:
|
||||
|
@ -256,8 +265,12 @@ public final class ElementName
|
|||
// return "DD_OR_DT";
|
||||
// case TreeBuilder.H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6:
|
||||
// return "H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6";
|
||||
// case TreeBuilder.OBJECT_OR_MARQUEE_OR_APPLET:
|
||||
// return "OBJECT_OR_MARQUEE_OR_APPLET";
|
||||
// case TreeBuilder.OBJECT:
|
||||
// return "OBJECT";
|
||||
// case TreeBuilder.OUTPUT_OR_LABEL:
|
||||
// return "OUTPUT_OR_LABEL";
|
||||
// case TreeBuilder.MARQUEE_OR_APPLET:
|
||||
// return "MARQUEE_OR_APPLET";
|
||||
// case TreeBuilder.PRE_OR_LISTING:
|
||||
// return "PRE_OR_LISTING";
|
||||
// case TreeBuilder.B_OR_BIG_OR_CODE_OR_EM_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U:
|
||||
|
@ -274,14 +287,16 @@ public final class ElementName
|
|||
// return "AREA_OR_BASEFONT_OR_BGSOUND_OR_SPACER_OR_WBR";
|
||||
// case TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU:
|
||||
// return "DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU";
|
||||
// case TreeBuilder.FIELDSET_OR_ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION:
|
||||
// return "FIELDSET_OR_ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION";
|
||||
// case TreeBuilder.CODE_OR_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR:
|
||||
// return "CODE_OR_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR";
|
||||
// case TreeBuilder.FIELDSET:
|
||||
// return "FIELDSET";
|
||||
// case TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION:
|
||||
// return "ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION";
|
||||
// case TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR:
|
||||
// return "RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR";
|
||||
// case TreeBuilder.RT_OR_RP:
|
||||
// return "RT_OR_RP";
|
||||
// case TreeBuilder.COMMAND_OR_EVENT_SOURCE:
|
||||
// return "COMMAND_OR_EVENT_SOURCE";
|
||||
// case TreeBuilder.COMMAND:
|
||||
// return "COMMAND";
|
||||
// case TreeBuilder.PARAM_OR_SOURCE:
|
||||
// return "PARAM_OR_SOURCE";
|
||||
// case TreeBuilder.MGLYPH_OR_MALIGNMARK:
|
||||
|
@ -385,7 +400,7 @@ public final class ElementName
|
|||
public static final ElementName COT = new ElementName("cot", "cot", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName DEL = new ElementName("del", "del", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName DFN = new ElementName("dfn", "dfn", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName DIR = new ElementName("dir", "dir", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName DIR = new ElementName("dir", "dir", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName DIV = new ElementName("div", "div", TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU, true, false, false);
|
||||
public static final ElementName EXP = new ElementName("exp", "exp", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName GCD = new ElementName("gcd", "gcd", TreeBuilder.OTHER, false, false, false);
|
||||
|
@ -404,7 +419,7 @@ public final class ElementName
|
|||
public static final ElementName MAX = new ElementName("max", "max", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName NEQ = new ElementName("neq", "neq", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName NOT = new ElementName("not", "not", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName NAV = new ElementName("nav", "nav", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName NAV = new ElementName("nav", "nav", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName PRE = new ElementName("pre", "pre", TreeBuilder.PRE_OR_LISTING, true, false, false);
|
||||
public static final ElementName REM = new ElementName("rem", "rem", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName SUB = new ElementName("sub", "sub", TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR, false, false, false);
|
||||
|
@ -477,7 +492,7 @@ public final class ElementName
|
|||
public static final ElementName TANH = new ElementName("tanh", "tanh", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName TEXT = new ElementName("text", "text", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName VIEW = new ElementName("view", "view", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName ASIDE = new ElementName("aside", "aside", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName ASIDE = new ElementName("aside", "aside", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName AUDIO = new ElementName("audio", "audio", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName APPLY = new ElementName("apply", "apply", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName EMBED = new ElementName("embed", "embed", TreeBuilder.EMBED_OR_IMG, true, false, false);
|
||||
|
@ -531,15 +546,15 @@ public final class ElementName
|
|||
public static final ElementName CANVAS = new ElementName("canvas", "canvas", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName DIVIDE = new ElementName("divide", "divide", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName DEGREE = new ElementName("degree", "degree", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName DIALOG = new ElementName("dialog", "dialog", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName DOMAIN = new ElementName("domain", "domain", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName EXISTS = new ElementName("exists", "exists", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName FETILE = new ElementName("fetile", "feTile", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName FIGURE = new ElementName("figure", "figure", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName FIGURE = new ElementName("figure", "figure", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName FORALL = new ElementName("forall", "forall", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName FILTER = new ElementName("filter", "filter", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName FOOTER = new ElementName("footer", "footer", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName HEADER = new ElementName("header", "header", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName FOOTER = new ElementName("footer", "footer", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName HGROUP = new ElementName("hgroup", "hgroup", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName HEADER = new ElementName("header", "header", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName IFRAME = new ElementName("iframe", "iframe", TreeBuilder.IFRAME, true, false, false);
|
||||
public static final ElementName KEYGEN = new ElementName("keygen", "keygen", TreeBuilder.KEYGEN, true, false, false);
|
||||
public static final ElementName LAMBDA = new ElementName("lambda", "lambda", TreeBuilder.OTHER, false, false, false);
|
||||
|
@ -569,7 +584,7 @@ public final class ElementName
|
|||
public static final ElementName SCRIPT = new ElementName("script", "script", TreeBuilder.SCRIPT, true, false, false);
|
||||
public static final ElementName TBREAK = new ElementName("tbreak", "tbreak", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName VECTOR = new ElementName("vector", "vector", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName ARTICLE = new ElementName("article", "article", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName ARTICLE = new ElementName("article", "article", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName ANIMATE = new ElementName("animate", "animate", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName ARCSECH = new ElementName("arcsech", "arcsech", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName ARCCSCH = new ElementName("arccsch", "arccsch", TreeBuilder.OTHER, false, false, false);
|
||||
|
@ -578,16 +593,16 @@ public final class ElementName
|
|||
public static final ElementName ARCCOSH = new ElementName("arccosh", "arccosh", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName ARCCOTH = new ElementName("arccoth", "arccoth", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName ACRONYM = new ElementName("acronym", "acronym", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName ADDRESS = new ElementName("address", "address", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName ADDRESS = new ElementName("address", "address", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName BGSOUND = new ElementName("bgsound", "bgsound", TreeBuilder.AREA_OR_BASEFONT_OR_BGSOUND_OR_SPACER_OR_WBR, true, false, false);
|
||||
public static final ElementName COMMAND = new ElementName("command", "command", TreeBuilder.COMMAND_OR_EVENT_SOURCE, true, false, false);
|
||||
public static final ElementName COMMAND = new ElementName("command", "command", TreeBuilder.COMMAND, true, false, false);
|
||||
public static final ElementName COMPOSE = new ElementName("compose", "compose", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName CEILING = new ElementName("ceiling", "ceiling", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName CSYMBOL = new ElementName("csymbol", "csymbol", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName CAPTION = new ElementName("caption", "caption", TreeBuilder.CAPTION, false, true, false);
|
||||
public static final ElementName DISCARD = new ElementName("discard", "discard", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName DECLARE = new ElementName("declare", "declare", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName DETAILS = new ElementName("details", "details", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName DETAILS = new ElementName("details", "details", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName ELLIPSE = new ElementName("ellipse", "ellipse", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName FEFUNCA = new ElementName("fefunca", "feFuncA", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName FEFUNCB = new ElementName("fefuncb", "feFuncB", TreeBuilder.OTHER, false, false, false);
|
||||
|
@ -613,7 +628,7 @@ public final class ElementName
|
|||
public static final ElementName PATTERN = new ElementName("pattern", "pattern", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName PRODUCT = new ElementName("product", "product", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName SETDIFF = new ElementName("setdiff", "setdiff", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName SECTION = new ElementName("section", "section", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName SECTION = new ElementName("section", "section", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName TENDSTO = new ElementName("tendsto", "tendsto", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName UPLIMIT = new ElementName("uplimit", "uplimit", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName ALTGLYPH = new ElementName("altglyph", "altGlyph", TreeBuilder.OTHER, false, false, false);
|
||||
|
@ -621,7 +636,7 @@ public final class ElementName
|
|||
public static final ElementName CLIPPATH = new ElementName("clippath", "clipPath", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName CODOMAIN = new ElementName("codomain", "codomain", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName COLGROUP = new ElementName("colgroup", "colgroup", TreeBuilder.COLGROUP, true, false, false);
|
||||
public static final ElementName DATAGRID = new ElementName("datagrid", "datagrid", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName DATAGRID = new ElementName("datagrid", "datagrid", TreeBuilder.ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION, true, false, false);
|
||||
public static final ElementName EMPTYSET = new ElementName("emptyset", "emptyset", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName FACTOROF = new ElementName("factorof", "factorof", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName FIELDSET = new ElementName("fieldset", "fieldset", TreeBuilder.FIELDSET, true, false, false);
|
||||
|
@ -678,7 +693,6 @@ public final class ElementName
|
|||
public static final ElementName SOLIDCOLOR = new ElementName("solidcolor", "solidcolor", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName ALTGLYPHDEF = new ElementName("altglyphdef", "altGlyphDef", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName DETERMINANT = new ElementName("determinant", "determinant", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName EVENTSOURCE = new ElementName("eventsource", "eventsource", TreeBuilder.COMMAND_OR_EVENT_SOURCE, true, false, false);
|
||||
public static final ElementName FEMERGENODE = new ElementName("femergenode", "feMergeNode", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName FECOMPOSITE = new ElementName("fecomposite", "feComposite", TreeBuilder.OTHER, false, false, false);
|
||||
public static final ElementName FESPOTLIGHT = new ElementName("fespotlight", "feSpotLight", TreeBuilder.OTHER, false, false, false);
|
||||
|
@ -923,7 +937,6 @@ public final class ElementName
|
|||
CANVAS,
|
||||
DIVIDE,
|
||||
DEGREE,
|
||||
DIALOG,
|
||||
DOMAIN,
|
||||
EXISTS,
|
||||
FETILE,
|
||||
|
@ -931,6 +944,7 @@ public final class ElementName
|
|||
FORALL,
|
||||
FILTER,
|
||||
FOOTER,
|
||||
HGROUP,
|
||||
HEADER,
|
||||
IFRAME,
|
||||
KEYGEN,
|
||||
|
@ -1070,7 +1084,6 @@ public final class ElementName
|
|||
SOLIDCOLOR,
|
||||
ALTGLYPHDEF,
|
||||
DETERMINANT,
|
||||
EVENTSOURCE,
|
||||
FEMERGENODE,
|
||||
FECOMPOSITE,
|
||||
FESPOTLIGHT,
|
||||
|
@ -1316,7 +1329,6 @@ public final class ElementName
|
|||
205096654,
|
||||
205689142,
|
||||
205690439,
|
||||
205766017,
|
||||
205988909,
|
||||
207213161,
|
||||
207794484,
|
||||
|
@ -1324,6 +1336,7 @@ public final class ElementName
|
|||
208023602,
|
||||
208213644,
|
||||
208213647,
|
||||
210261490,
|
||||
210310273,
|
||||
210940978,
|
||||
213325049,
|
||||
|
@ -1463,7 +1476,6 @@ public final class ElementName
|
|||
356072847,
|
||||
370349192,
|
||||
373962798,
|
||||
374509141,
|
||||
375558638,
|
||||
375574835,
|
||||
376053993,
|
||||
|
@ -1509,5 +1521,4 @@ public final class ElementName
|
|||
644420819,
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import nu.validator.htmlparser.annotation.Local;
|
|||
import nu.validator.htmlparser.annotation.NsUri;
|
||||
import nu.validator.htmlparser.annotation.Prefix;
|
||||
import nu.validator.htmlparser.annotation.QName;
|
||||
import nu.validator.htmlparser.common.Interner;
|
||||
import nu.validator.htmlparser.common.XmlViolationPolicy;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
|
@ -447,6 +448,25 @@ public final class HtmlAttributes implements Attributes {
|
|||
mode = AttributeName.SVG;
|
||||
}
|
||||
|
||||
public HtmlAttributes cloneAttributes(Interner interner) throws SAXException {
|
||||
assert (length == 0 && xmlnsLength == 0) || 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[
|
||||
, XmlViolationPolicy.ALLOW
|
||||
// ]NOCPP]
|
||||
);
|
||||
}
|
||||
// [NOCPP[
|
||||
for (int i = 0; i < xmlnsLength; i++) {
|
||||
clone.addAttribute(xmlnsNames[i],
|
||||
xmlnsValues[i], XmlViolationPolicy.ALLOW);
|
||||
}
|
||||
// ]NOCPP]
|
||||
return clone; // XXX!!!
|
||||
}
|
||||
|
||||
// [NOCPP[
|
||||
|
||||
void processNonNcNames(TreeBuilder<?> treeBuilder, XmlViolationPolicy namePolicy) throws SAXException {
|
||||
|
@ -481,6 +501,7 @@ public final class HtmlAttributes implements Attributes {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// ]NOCPP]
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ package nu.validator.htmlparser.impl;
|
|||
import nu.validator.htmlparser.annotation.Literal;
|
||||
import nu.validator.htmlparser.annotation.Local;
|
||||
import nu.validator.htmlparser.annotation.NoLength;
|
||||
import nu.validator.htmlparser.common.Interner;
|
||||
|
||||
public final class Portability {
|
||||
|
||||
|
@ -34,7 +35,7 @@ public final class Portability {
|
|||
* Allocates a new local name object. In C++, the refcount must be set up in such a way that
|
||||
* calling <code>releaseLocal</code> on the return value balances the refcount set by this method.
|
||||
*/
|
||||
public static @Local String newLocalNameFromBuffer(@NoLength char[] buf, int offset, int length) {
|
||||
public static @Local String newLocalNameFromBuffer(@NoLength char[] buf, int offset, int length, Interner interner) {
|
||||
return new String(buf, offset, length).intern();
|
||||
}
|
||||
|
||||
|
@ -50,6 +51,10 @@ public final class Portability {
|
|||
return literal;
|
||||
}
|
||||
|
||||
public static String newStringFromString(String string) {
|
||||
return string;
|
||||
}
|
||||
|
||||
// XXX get rid of this
|
||||
public static char[] newCharArrayFromLocal(@Local String local) {
|
||||
return local.toCharArray();
|
||||
|
@ -59,6 +64,10 @@ public final class Portability {
|
|||
return string.toCharArray();
|
||||
}
|
||||
|
||||
public static @Local String newLocalFromLocal(@Local String local, Interner interner) {
|
||||
return local;
|
||||
}
|
||||
|
||||
// Deallocation methods
|
||||
|
||||
public static void releaseString(String str) {
|
||||
|
@ -85,6 +94,9 @@ public final class Portability {
|
|||
// No-op in Java
|
||||
}
|
||||
|
||||
// [NOCPP[
|
||||
// These are no longer used in Gecko. Need to decide what to do about these in the long term.
|
||||
|
||||
public static void retainElement(Object elt) {
|
||||
// No-op in Java
|
||||
}
|
||||
|
@ -93,6 +105,8 @@ public final class Portability {
|
|||
// No-op in Java
|
||||
}
|
||||
|
||||
// ]NOCPP]
|
||||
|
||||
// Comparison methods
|
||||
|
||||
public static boolean localEqualsBuffer(@Local String local, @NoLength char[] buf, int offset, int length) {
|
||||
|
|
|
@ -43,8 +43,11 @@ final class StackNode<T> {
|
|||
|
||||
final boolean fosterParenting;
|
||||
|
||||
private int refcount = 1;
|
||||
// Only used on the list of formatting elements
|
||||
HtmlAttributes attributes;
|
||||
|
||||
private int refcount = 1;
|
||||
|
||||
/**
|
||||
* @param group
|
||||
* TODO
|
||||
|
@ -57,7 +60,7 @@ final class StackNode<T> {
|
|||
*/
|
||||
StackNode(int group, final @NsUri String ns, final @Local String name, final T node,
|
||||
final boolean scoping, final boolean special,
|
||||
final boolean fosterParenting, final @Local String popName) {
|
||||
final boolean fosterParenting, final @Local String popName, HtmlAttributes attributes) {
|
||||
this.group = group;
|
||||
this.name = name;
|
||||
this.popName = popName;
|
||||
|
@ -66,6 +69,7 @@ final class StackNode<T> {
|
|||
this.scoping = scoping;
|
||||
this.special = special;
|
||||
this.fosterParenting = fosterParenting;
|
||||
this.attributes = attributes;
|
||||
this.refcount = 1;
|
||||
Portability.retainLocal(name);
|
||||
Portability.retainLocal(popName);
|
||||
|
@ -87,6 +91,24 @@ final class StackNode<T> {
|
|||
this.scoping = elementName.scoping;
|
||||
this.special = elementName.special;
|
||||
this.fosterParenting = elementName.fosterParenting;
|
||||
this.attributes = null;
|
||||
this.refcount = 1;
|
||||
Portability.retainLocal(name);
|
||||
Portability.retainLocal(popName);
|
||||
Portability.retainElement(node);
|
||||
// not retaining namespace for now
|
||||
}
|
||||
|
||||
StackNode(final @NsUri String ns, ElementName elementName, final T node, HtmlAttributes attributes) {
|
||||
this.group = elementName.group;
|
||||
this.name = elementName.name;
|
||||
this.popName = elementName.name;
|
||||
this.ns = ns;
|
||||
this.node = node;
|
||||
this.scoping = elementName.scoping;
|
||||
this.special = elementName.special;
|
||||
this.fosterParenting = elementName.fosterParenting;
|
||||
this.attributes = attributes;
|
||||
this.refcount = 1;
|
||||
Portability.retainLocal(name);
|
||||
Portability.retainLocal(popName);
|
||||
|
@ -103,6 +125,7 @@ final class StackNode<T> {
|
|||
this.scoping = elementName.scoping;
|
||||
this.special = elementName.special;
|
||||
this.fosterParenting = elementName.fosterParenting;
|
||||
this.attributes = null;
|
||||
this.refcount = 1;
|
||||
Portability.retainLocal(name);
|
||||
Portability.retainLocal(popName);
|
||||
|
@ -119,6 +142,7 @@ final class StackNode<T> {
|
|||
this.scoping = scoping;
|
||||
this.special = false;
|
||||
this.fosterParenting = false;
|
||||
this.attributes = null;
|
||||
this.refcount = 1;
|
||||
Portability.retainLocal(name);
|
||||
Portability.retainLocal(popName);
|
||||
|
@ -130,7 +154,12 @@ final class StackNode<T> {
|
|||
Portability.releaseLocal(name);
|
||||
Portability.releaseLocal(popName);
|
||||
Portability.releaseElement(node);
|
||||
// not releasing namespace for now
|
||||
// not releasing namespace for now
|
||||
Portability.delete(attributes);
|
||||
}
|
||||
|
||||
public void dropAttributes() {
|
||||
attributes = null;
|
||||
}
|
||||
|
||||
// [NOCPP[
|
||||
|
|
|
@ -23,26 +23,150 @@
|
|||
package nu.validator.htmlparser.impl;
|
||||
|
||||
|
||||
public class StateSnapshot<T> {
|
||||
public class StateSnapshot<T> implements TreeBuilderState<T> {
|
||||
|
||||
private final StackNode<T>[] stack;
|
||||
|
||||
private final StackNode<T>[] listOfActiveFormattingElements;
|
||||
|
||||
private final T formPointer;
|
||||
|
||||
private final T headPointer;
|
||||
|
||||
private final int mode;
|
||||
|
||||
private final int originalMode;
|
||||
|
||||
private final boolean framesetOk;
|
||||
|
||||
private final int foreignFlag;
|
||||
|
||||
private final boolean needToDropLF;
|
||||
|
||||
private final boolean quirks;
|
||||
|
||||
/**
|
||||
* @param stack
|
||||
* @param listOfActiveFormattingElements
|
||||
* @param formPointer
|
||||
* @param quirks
|
||||
* @param needToDropLF
|
||||
* @param foreignFlag
|
||||
* @param originalMode
|
||||
* @param mode
|
||||
*/
|
||||
StateSnapshot(StackNode<T>[] stack,
|
||||
StackNode<T>[] listOfActiveFormattingElements, T formPointer) {
|
||||
StackNode<T>[] listOfActiveFormattingElements, T formPointer, T headPointer, int mode, int originalMode, boolean framesetOk, int foreignFlag, boolean needToDropLF, boolean quirks) {
|
||||
this.stack = stack;
|
||||
this.listOfActiveFormattingElements = listOfActiveFormattingElements;
|
||||
this.formPointer = formPointer;
|
||||
this.headPointer = headPointer;
|
||||
this.mode = mode;
|
||||
this.originalMode = originalMode;
|
||||
this.framesetOk = framesetOk;
|
||||
this.foreignFlag = foreignFlag;
|
||||
this.needToDropLF = needToDropLF;
|
||||
this.quirks = quirks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see nu.validator.htmlparser.impl.TreeBuilderState#getStack()
|
||||
*/
|
||||
public StackNode<T>[] getStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
final StackNode<T>[] stack;
|
||||
/**
|
||||
* @see nu.validator.htmlparser.impl.TreeBuilderState#getListOfActiveFormattingElements()
|
||||
*/
|
||||
public StackNode<T>[] getListOfActiveFormattingElements() {
|
||||
return listOfActiveFormattingElements;
|
||||
}
|
||||
|
||||
final StackNode<T>[] listOfActiveFormattingElements;
|
||||
/**
|
||||
* @see nu.validator.htmlparser.impl.TreeBuilderState#getFormPointer()
|
||||
*/
|
||||
public T getFormPointer() {
|
||||
return formPointer;
|
||||
}
|
||||
|
||||
final T formPointer;
|
||||
/**
|
||||
* Returns the headPointer.
|
||||
*
|
||||
* @return the headPointer
|
||||
*/
|
||||
public T getHeadPointer() {
|
||||
return headPointer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mode.
|
||||
*
|
||||
* @return the mode
|
||||
*/
|
||||
public int getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the originalMode.
|
||||
*
|
||||
* @return the originalMode
|
||||
*/
|
||||
public int getOriginalMode() {
|
||||
return originalMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the framesetOk.
|
||||
*
|
||||
* @return the framesetOk
|
||||
*/
|
||||
public boolean isFramesetOk() {
|
||||
return framesetOk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the foreignFlag.
|
||||
*
|
||||
* @return the foreignFlag
|
||||
*/
|
||||
public int getForeignFlag() {
|
||||
return foreignFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the needToDropLF.
|
||||
*
|
||||
* @return the needToDropLF
|
||||
*/
|
||||
public boolean isNeedToDropLF() {
|
||||
return needToDropLF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quirks.
|
||||
*
|
||||
* @return the quirks
|
||||
*/
|
||||
public boolean isQuirks() {
|
||||
return quirks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see nu.validator.htmlparser.impl.TreeBuilderState#getListLength()
|
||||
*/
|
||||
public int getListLength() {
|
||||
return listOfActiveFormattingElements.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see nu.validator.htmlparser.impl.TreeBuilderState#getStackLength()
|
||||
*/
|
||||
public int getStackLength() {
|
||||
return stack.length;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") private void destructor() {
|
||||
for (int i = 0; i < stack.length; i++) {
|
||||
stack[i].release();
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче