Skip to content
Snippets Groups Projects
Commit a7c89667 authored by Markus Koschany's avatar Markus Koschany
Browse files

Merge tag 'upstream/1.4+r1.3.1'

Upstream version 1.4+r1.3.1

# gpg: Signature made Mon 11 Jan 2016 20:51:34 CET using RSA key ID 513B51E4
# gpg: Good signature from "Markus Koschany <apo@gambaru.de>" [ultimate]
# gpg:                 aka "Markus Koschany <markus@koschany.net>" [ultimate]
# gpg:                 aka "Markus Koschany <apo@debian.org>" [ultimate]
parents 0f8e11b3 88717855
No related branches found
No related tags found
No related merge requests found
Showing
with 330 additions and 956 deletions
......@@ -4,7 +4,7 @@ For the copyright notices for individual files, please see individual files.
/*
* Copyright (c) 2005, 2006, 2007 Henri Sivonen
* Copyright (c) 2007-2012 Mozilla Foundation
* Copyright (c) 2007-2011 Mozilla Foundation
* Portions of comments Copyright 2004-2007 Apple Computer, Inc., Mozilla
* Foundation, and Opera Software ASA.
*
......
<!--
* Copyright (c) 2007-2012 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nu.validator.htmlparser</groupId>
<artifactId>htmlparser</artifactId>
<packaging>bundle</packaging>
<version>1.4</version>
<packaging>jar</packaging>
<version>1.3.1</version>
<name>htmlparser</name>
<url>http://about.validator.nu/htmlparser/</url>
<description>The Validator.nu HTML Parser is an implementation of the HTML5 parsing algorithm in Java for applications. The parser is designed to work as a drop-in replacement for the XML parser in applications that already support XHTML 1.x content with an XML parser and use SAX, DOM or XOM to interface with the parser.</description>
<!--
Usage notes for this POM:
To build without signing, run:
mvn clean source:jar javadoc:jar repository:bundle-create
(enter 0 <return> when prompted)
To build and sign, run:
mvn clean source:jar javadoc:jar package gpg:sign repository:bundle-create
(enter 0 <return> when prompted)
This POM file is used for creating the bundle for distribution via the
Maven Central Repository. It is not used as part of the normal development
process of the parser and the maintainer of the parser (Henri Sivonen)
isn't experienced in POM tweaking. If you need this POM to do something
that it currently does not do or do something better, you need to write
the changes you need yourself and contribute a patch via
http://bugzilla.validator.nu/
-->
<description>The Validator.nu HTML Parser is an implementation of the HTML5 parsing algorithm in Java for applications that do not run scripts. The parser is designed to work as a drop-in replacement for the XML parser in applications that already support XHTML 1.x content with an XML parser and use SAX, DOM or XOM to interface with the parser.</description>
<developers>
<developer>
<id>hsivonen</id>
......@@ -69,11 +29,10 @@
</license>
</licenses>
<scm>
<connection>scm:hg:http://hg.mozilla.org/projects/htmlparser/</connection>
<url>http://hg.mozilla.org/projects/htmlparser/</url>
<connection>scm:svn:http://svn.versiondude.net/whattf/htmlparser/</connection>
</scm>
<build>
<sourceDirectory>${project.build.directory}/src</sourceDirectory>
<sourceDirectory>${basedir}/src</sourceDirectory>
<testSourceDirectory>${basedir}/test-src</testSourceDirectory>
<plugins>
<plugin>
......@@ -84,59 +43,6 @@
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
<executions>
<execution>
<id>intitialize-sources</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete dir="${project.build.sourceDirectory}"/>
<mkdir dir="${project.build.sourceDirectory}"/>
<copy todir="${project.build.sourceDirectory}">
<fileset dir="${basedir}/src"/>
</copy>
</target>
</configuration>
</execution>
<execution>
<id>tokenizer-hotspot-workaround</id>
<phase>process-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="translator.sources" value="${basedir}/translator-src"/>
<property name="translator.classes" value="${project.build.directory}/translator-classes"/>
<mkdir dir="${translator.classes}"/>
<javac srcdir="${translator.sources}" includes="nu/validator/htmlparser/generator/ApplyHotSpotWorkaround.java" destdir="${translator.classes}" includeantruntime="false"/>
<java classname="nu.validator.htmlparser.generator.ApplyHotSpotWorkaround">
<classpath>
<pathelement location="${translator.classes}"/>
</classpath>
<arg value="${project.build.sourceDirectory}/nu/validator/htmlparser/impl/Tokenizer.java"/>
<arg value="${project.build.sourceDirectory}/nu/validator/htmlparser/impl/HotSpotWorkaround.txt"/>
</java>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
......@@ -144,24 +50,6 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<instructions>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-SymbolicName>nu.validator.htmlparser</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-RequiredExecutionEnvironment>J2SE-1.5</Bundle-RequiredExecutionEnvironment>
<_removeheaders>Built-By,Bnd-LastModified</_removeheaders>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
......@@ -235,6 +123,5 @@
<properties>
<rpm.java.dir>/usr/share/java</rpm.java.dir>
<rpm.javadoc.dir>/usr/share/javadoc</rpm.javadoc.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
......@@ -351,9 +351,7 @@ public class HtmlDocumentBuilder extends DocumentBuilder {
*/
@Override public void setErrorHandler(ErrorHandler errorHandler) {
treeBuilder.setErrorHandler(errorHandler);
if (driver != null) {
driver.setErrorHandler(errorHandler);
}
driver.setErrorHandler(errorHandler);
}
public void setTransitionHander(TransitionHandler handler) {
......
......@@ -785,7 +785,6 @@ public final class AttributeName
public static final AttributeName MASK = new AttributeName(ALL_NO_NS, SAME_LOCAL("mask"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName LINK = new AttributeName(ALL_NO_NS, SAME_LOCAL("link"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName LANG = new AttributeName(LANG_NS, SAME_LOCAL("lang"), LANG_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName LOOP = new AttributeName(ALL_NO_NS, SAME_LOCAL("loop"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName LIST = new AttributeName(ALL_NO_NS, SAME_LOCAL("list"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName TYPE = new AttributeName(ALL_NO_NS, SAME_LOCAL("type"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG | CASE_FOLDED);
public static final AttributeName WHEN = new AttributeName(ALL_NO_NS, SAME_LOCAL("when"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
......@@ -930,6 +929,7 @@ public final class AttributeName
public static final AttributeName NOSHADE = new AttributeName(ALL_NO_NS, SAME_LOCAL("noshade"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG | CASE_FOLDED | BOOLEAN);
public static final AttributeName MINSIZE = new AttributeName(ALL_NO_NS, SAME_LOCAL("minsize"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName MAXSIZE = new AttributeName(ALL_NO_NS, SAME_LOCAL("maxsize"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName LOOPEND = new AttributeName(ALL_NO_NS, SAME_LOCAL("loopend"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName LARGEOP = new AttributeName(ALL_NO_NS, SAME_LOCAL("largeop"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName UNICODE = new AttributeName(ALL_NO_NS, SAME_LOCAL("unicode"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName TARGETX = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("targetx", "targetX"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
......@@ -1027,12 +1027,14 @@ public final class AttributeName
public static final AttributeName MASKUNITS = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("maskunits", "maskUnits"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName MAXLENGTH = new AttributeName(ALL_NO_NS, SAME_LOCAL("maxlength"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName LINEBREAK = new AttributeName(ALL_NO_NS, SAME_LOCAL("linebreak"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName LOOPSTART = new AttributeName(ALL_NO_NS, SAME_LOCAL("loopstart"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName TRANSFORM = new AttributeName(ALL_NO_NS, SAME_LOCAL("transform"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName V_HANGING = new AttributeName(ALL_NO_NS, SAME_LOCAL("v-hanging"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName VALUETYPE = new AttributeName(ALL_NO_NS, SAME_LOCAL("valuetype"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG | CASE_FOLDED);
public static final AttributeName POINTSATZ = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("pointsatz", "pointsAtZ"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName POINTSATX = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("pointsatx", "pointsAtX"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName POINTSATY = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("pointsaty", "pointsAtY"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName PLAYCOUNT = new AttributeName(ALL_NO_NS, SAME_LOCAL("playcount"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName SYMMETRIC = new AttributeName(ALL_NO_NS, SAME_LOCAL("symmetric"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName SCROLLING = new AttributeName(ALL_NO_NS, SAME_LOCAL("scrolling"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG | CASE_FOLDED);
public static final AttributeName REPEATDUR = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("repeatdur", "repeatDur"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
......@@ -1092,7 +1094,6 @@ public final class AttributeName
public static final AttributeName CELLPADDING = new AttributeName(ALL_NO_NS, SAME_LOCAL("cellpadding"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName CELLSPACING = new AttributeName(ALL_NO_NS, SAME_LOCAL("cellspacing"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName COLUMNWIDTH = new AttributeName(ALL_NO_NS, SAME_LOCAL("columnwidth"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName CROSSORIGIN = new AttributeName(ALL_NO_NS, SAME_LOCAL("crossorigin"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName COLUMNALIGN = new AttributeName(ALL_NO_NS, SAME_LOCAL("columnalign"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName COLUMNLINES = new AttributeName(ALL_NO_NS, SAME_LOCAL("columnlines"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName CONTEXTMENU = new AttributeName(ALL_NO_NS, SAME_LOCAL("contextmenu"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
......@@ -1366,7 +1367,6 @@ public final class AttributeName
MASK,
LINK,
LANG,
LOOP,
LIST,
TYPE,
WHEN,
......@@ -1511,6 +1511,7 @@ public final class AttributeName
NOSHADE,
MINSIZE,
MAXSIZE,
LOOPEND,
LARGEOP,
UNICODE,
TARGETX,
......@@ -1608,12 +1609,14 @@ public final class AttributeName
MASKUNITS,
MAXLENGTH,
LINEBREAK,
LOOPSTART,
TRANSFORM,
V_HANGING,
VALUETYPE,
POINTSATZ,
POINTSATX,
POINTSATY,
PLAYCOUNT,
SYMMETRIC,
SCROLLING,
REPEATDUR,
......@@ -1673,7 +1676,6 @@ public final class AttributeName
CELLPADDING,
CELLSPACING,
COLUMNWIDTH,
CROSSORIGIN,
COLUMNALIGN,
COLUMNLINES,
CONTEXTMENU,
......@@ -1948,7 +1950,6 @@ public final class AttributeName
149809441,
150018784,
150445028,
150813181,
150923321,
152528754,
152536216,
......@@ -2093,6 +2094,7 @@ public final class AttributeName
249533729,
250235623,
250269543,
251083937,
251402351,
252339047,
253260911,
......@@ -2190,12 +2192,14 @@ public final class AttributeName
316797986,
317486755,
317794164,
318721061,
320076137,
322657125,
322887778,
323506876,
323572412,
323605180,
323938869,
325060058,
325320188,
325398738,
......@@ -2255,7 +2259,6 @@ public final class AttributeName
371448425,
371448430,
371545055,
371593469,
371596922,
371758751,
371964792,
......
......@@ -370,8 +370,6 @@ public final class ElementName
// return "ANNOTATION_XML";
// case TreeBuilder.FOREIGNOBJECT_OR_DESC:
// return "FOREIGNOBJECT_OR_DESC";
// case TreeBuilder.MENUITEM:
// return "MENUITEM";
// }
// return null;
// }
......@@ -715,7 +713,6 @@ public final class ElementName
public static final ElementName LOWLIMIT = new ElementName("lowlimit", "lowlimit", TreeBuilder.OTHER);
public static final ElementName METADATA = new ElementName("metadata", "metadata", TreeBuilder.OTHER);
public static final ElementName MENCLOSE = new ElementName("menclose", "menclose", TreeBuilder.OTHER);
public static final ElementName MENUITEM = new ElementName("menuitem", "menuitem", TreeBuilder.MENUITEM | SPECIAL);
public static final ElementName MPHANTOM = new ElementName("mphantom", "mphantom", TreeBuilder.OTHER);
public static final ElementName NOFRAMES = new ElementName("noframes", "noframes", TreeBuilder.NOFRAMES | SPECIAL);
public static final ElementName NOSCRIPT = new ElementName("noscript", "noscript", TreeBuilder.NOSCRIPT | SPECIAL);
......@@ -1108,7 +1105,6 @@ public final class ElementName
LOWLIMIT,
METADATA,
MENCLOSE,
MENUITEM,
MPHANTOM,
NOFRAMES,
NOSCRIPT,
......@@ -1502,7 +1498,6 @@ public final class ElementName
281683369,
282120228,
282250732,
282498697,
282508942,
283743649,
283787570,
......
......@@ -477,7 +477,7 @@ public class ErrorReportingTokenizer extends Tokenizer {
}
@Override protected void errSlashNotFollowedByGt() throws SAXException {
err("A slash was not immediately followed by \u201C>\u201D.");
err("A slash was not immediate followed by \u201C>\u201D.");
}
@Override protected void errHtml4XmlVoidSyntax() throws SAXException {
......
......@@ -20,12 +20,6 @@
* DEALINGS IN THE SOFTWARE.
*/
/**
* compressed returnValue:
* int returnState = returnValue >> 33
* boolean breakOuterState = ((returnValue >> 32) & 0x1) != 0)
* int pos = returnValue & 0xFFFFFFFF // same as (int)returnValue
*/
@SuppressWarnings("unused") private long workAroundHotSpotHugeMethodLimit(
int state, char c, int pos, @NoLength char[] buf,
boolean reconsume, int returnState, int endPos) throws SAXException {
......@@ -36,20 +30,18 @@
long returnStateAndPos = workAroundHotSpotHugeMethodLimit(
state, c, pos, buf, reconsume, returnState, endPos);
pos = (int)returnStateAndPos; // 5.1.3 in the Java spec
returnState = (int)(returnStateAndPos >> 33);
returnState = (int)(returnStateAndPos >> 32);
state = stateSave;
if ( (pos == endPos) || ( (((int)(returnStateAndPos >> 32)) & 0x1) != 0) ) {
if (pos == endPos) {
break stateloop;
}
continue stateloop;
// END HOTSPOT WORKAROUND
default:
assert !reconsume : "Must not reconsume when returning from HotSpot workaround.";
stateSave = state;
return (((long)returnState) << 33) | pos;
break stateloop;
}
}
assert !reconsume : "Must not reconsume when returning from HotSpot workaround.";
stateSave = state;
return (((long)returnState) << 33) | (1L << 32) | pos ;
return (((long)returnState) << 32) | pos;
}
......@@ -578,8 +578,8 @@ public abstract class MetaScanner {
state = MetaScanner.ATTRIBUTE_NAME;
continue stateloop;
default:
contentIndex = Integer.MAX_VALUE;
charsetIndex = Integer.MAX_VALUE;
contentIndex = -1;
charsetIndex = -1;
state = MetaScanner.ATTRIBUTE_NAME;
continue stateloop;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -51,8 +51,6 @@ public final class UTF16Buffer {
*/
private int end;
//[NOCPP[
/**
* Constructor for wrapping an existing UTF-16 code unit array.
*
......@@ -69,8 +67,6 @@ public final class UTF16Buffer {
this.end = end;
}
// ]NOCPP]
/**
* Returns the start index.
*
......
......@@ -282,12 +282,9 @@ public final class HtmlInputStreamReader extends Reader implements
} else {
// The usual stuff. Want more bytes next time.
shouldReadBytes = true;
// return -1 if zero
int cPos = charBuffer.position();
if (cPos == 0) {
// No output. Read more bytes right away
break;
}
return cPos;
return cPos == 0 ? -1 : cPos;
}
} else {
// The result is in error. No need to test.
......
......@@ -155,7 +155,7 @@ public class XmlSerializer implements ContentHandler, LexicalHandler {
"xlink");
WELL_KNOWN_ATTRIBUTE_PREFIXES.put(
"http://www.w3.org/2001/XMLSchema-instance", "xsi");
WELL_KNOWN_ATTRIBUTE_PREFIXES.put("http://www.w3.org/1999/xlink",
WELL_KNOWN_ATTRIBUTE_PREFIXES.put("http://www.w3org/1999/xlink",
"xlink");
}
......
......@@ -101,24 +101,18 @@ public class CppTypes {
"nsINameSpaceManager", "nsIContent", "nsIDocument",
"nsTraceRefcnt", "jArray", "nsHtml5DocumentMode",
"nsHtml5ArrayCopy", "nsHtml5Parser", "nsHtml5Atoms",
"nsHtml5TreeOperation", "nsHtml5PendingNotification",
"nsHtml5StateSnapshot", "nsHtml5StackNode",
"nsHtml5TreeOpExecutor", "nsHtml5StreamParser",
"nsAHtml5TreeBuilderState", "nsHtml5Highlighter",
"nsHtml5ViewSourceUtils" };
private static final String[] TOKENIZER_INCLUDES = { "prtypes", "nsIAtom",
"nsHtml5AtomTable", "nsString", "nsIContent", "nsTraceRefcnt",
"jArray", "nsHtml5DocumentMode", "nsHtml5ArrayCopy",
"nsHtml5NamedCharacters", "nsHtml5NamedCharactersAccel",
"nsHtml5Atoms", "nsAHtml5TreeBuilderState", "nsHtml5Macros",
"nsHtml5Highlighter", "nsHtml5TokenizerLoopPolicies" };
"nsHtml5ByteReadable", "nsHtml5TreeOperation",
"nsHtml5PendingNotification", "nsHtml5StateSnapshot",
"nsHtml5StackNode", "nsHtml5TreeOpExecutor", "nsHtml5StreamParser",
"nsAHtml5TreeBuilderState" };
private static final String[] INCLUDES = { "prtypes", "nsIAtom",
"nsHtml5AtomTable", "nsString", "nsINameSpaceManager",
"nsIContent", "nsTraceRefcnt", "jArray", "nsHtml5ArrayCopy",
"nsAHtml5TreeBuilderState", "nsHtml5Atoms", "nsHtml5ByteReadable",
"nsIUnicodeDecoder", "nsHtml5Macros" };
"nsIContent", "nsIDocument", "nsTraceRefcnt", "jArray",
"nsHtml5DocumentMode", "nsHtml5ArrayCopy",
"nsHtml5NamedCharacters", "nsHtml5NamedCharactersAccel",
"nsHtml5Atoms", "nsHtml5ByteReadable", "nsIUnicodeDecoder",
"nsAHtml5TreeBuilderState", "nsHtml5Macros" };
private static final String[] OTHER_DECLATIONS = {};
......@@ -127,14 +121,10 @@ public class CppTypes {
private static final String[] NAMED_CHARACTERS_INCLUDES = { "prtypes",
"jArray", "nscore", "nsDebug", "prlog", "nsMemory" };
private static final String[] FORWARD_DECLARATIONS = {
"nsHtml5StreamParser" };
private static final String[] FORWARD_DECLARATIONS = { "nsHtml5StreamParser", };
private static final String[] CLASSES_THAT_NEED_SUPPLEMENT = {
"MetaScanner", "Tokenizer", "TreeBuilder", "UTF16Buffer", };
private static final String[] STATE_LOOP_POLICIES = {
"nsHtml5ViewSourcePolicy", "nsHtml5SilentPolicy" };
"MetaScanner", "TreeBuilder", "UTF16Buffer", };
private final Map<String, String> atomMap = new HashMap<String, String>();
......@@ -170,7 +160,7 @@ public class CppTypes {
}
public String booleanType() {
return "bool";
return "PRBool";
}
public String byteType() {
......@@ -210,11 +200,11 @@ public class CppTypes {
}
public String falseLiteral() {
return "false";
return "PR_FALSE";
}
public String trueLiteral() {
return "true";
return "PR_TRUE";
}
public String nullLiteral() {
......@@ -309,8 +299,6 @@ public class CppTypes {
public String[] boilerplateIncludes(String javaClass) {
if ("TreeBuilder".equals(javaClass)) {
return TREE_BUILDER_INCLUDES;
} else if ("Tokenizer".equals(javaClass)) {
return TOKENIZER_INCLUDES;
} else {
return INCLUDES;
}
......@@ -403,28 +391,4 @@ public class CppTypes {
public String characterNameTypeDeclaration() {
return "nsHtml5CharacterName";
}
public String transition() {
return "P::transition";
}
public String tokenizerErrorCondition() {
return "P::reportErrors";
}
public String firstTransitionArg() {
return "mViewSource";
}
public String errorHandler() {
return "NS_UNLIKELY(mViewSource)";
}
public String completedCharacterReference() {
return "P::completedNamedCharacterReference(mViewSource)";
}
public String[] stateLoopPolicies() {
return STATE_LOOP_POLICIES;
}
}
......@@ -151,11 +151,6 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
}
}
public void printWithoutIndent(String arg) {
indented = false;
buf.append(arg);
}
public void print(String arg) {
if (!indented) {
makeIndent();
......@@ -183,8 +178,15 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
}
}
private boolean supportErrorReporting = true;
private boolean skipRestOfStatementsInBlock = false;
private String currentTokenizerState = null;
private boolean inTokenizerLoop() {
return "stateLoop".equals(currentMethod)
&& "Tokenizer".equals(javaClassName);
}
protected SourcePrinter printer = new SourcePrinter();
private SourcePrinter staticInitializerPrinter = new SourcePrinter();
......@@ -221,10 +223,6 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
protected boolean inStatic = false;
private boolean reportTransitions = false;
private int stateLoopCallCount = 0;
/**
* @param cppTypes
*/
......@@ -255,13 +253,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
private void printMembers(List<BodyDeclaration> members,
LocalSymbolTable arg) {
for (BodyDeclaration member : members) {
if ("Tokenizer".equals(javaClassName)
&& member instanceof MethodDeclaration
&& "stateLoop".equals(((MethodDeclaration) member).getName())) {
reportTransitions = true;
}
member.accept(this, arg);
reportTransitions = false;
}
}
......@@ -325,8 +317,6 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
printer.print(cppTypes.localForLiteral("html"));
} else if ("documentModeHandler".equals(n.getName())) {
printer.print("this");
} else if ("errorHandler".equals(n.getName())) {
printer.print(cppTypes.errorHandler());
} else {
String prefixedName = javaClassName + "." + n.getName();
String constant = symbolTable.cppDefinesByJavaNames.get(prefixedName);
......@@ -1344,14 +1334,6 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
}
printTypeArgs(n.getTypeArgs(), arg);
printer.print(n.getName());
if ("stateLoop".equals(n.getName())
&& "Tokenizer".equals(javaClassName)
&& cppTypes.stateLoopPolicies().length > 0) {
printer.print("<");
printer.print(cppTypes.stateLoopPolicies()[stateLoopCallCount]);
printer.print(">");
stateLoopCallCount++;
}
printer.print("(");
if (n.getArgs() != null) {
for (Iterator<Expression> i = n.getArgs().iterator(); i.hasNext();) {
......@@ -1554,7 +1536,7 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
currentMethod = n.getName();
destructor = "destructor".equals(currentMethod);
destructor = "destructor".equals(n.getName());
// if (n.getJavaDoc() != null) {
// n.getJavaDoc().accept(this, arg);
......@@ -1571,17 +1553,6 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
printModifiers(n.getModifiers());
}
if ("stateLoop".equals(currentMethod)
&& "Tokenizer".equals(javaClassName)
&& cppTypes.stateLoopPolicies().length > 0) {
printer.print("template<class P>");
if (inHeader()) {
printer.print(" ");
} else {
printer.printLn();
}
}
printTypeParameters(n.getTypeParameters(), arg);
if (n.getTypeParameters() != null) {
printer.print(" ");
......@@ -1769,96 +1740,27 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
public void visit(ExpressionStmt n, LocalSymbolTable arg) {
Expression e = n.getExpression();
if (isCompletedCharacterReference(e)) {
printer.print(cppTypes.completedCharacterReference());
printer.print(";");
return;
}
boolean needsCondition = isTokenizerErrorReportingExpression(e);
if (!needsCondition && isDroppedExpression(e)) {
if (isDroppedExpression(e)) {
return;
}
if (needsCondition) {
printer.print("if (");
printer.print(cppTypes.tokenizerErrorCondition());
printer.printLn(") {");
printer.indent();
}
e.accept(this, arg);
if (!inConstructorBody) {
printer.print(";");
}
if (needsCondition) {
printer.printLn();
printer.unindent();
printer.print("}");
}
}
private void visitTransition(MethodCallExpr call, LocalSymbolTable arg) {
List<Expression> args = call.getArgs();
if (reportTransitions) {
printer.print(cppTypes.transition());
printer.print("(");
printer.print(cppTypes.firstTransitionArg());
printer.print(", ");
args.get(1).accept(this, arg);
printer.print(", ");
args.get(2).accept(this, arg);
printer.print(", ");
args.get(3).accept(this, arg);
printer.print(")");
} else {
args.get(1).accept(this, arg);
}
args.get(1).accept(this, arg);
}
private boolean isTokenizerErrorReportingExpression(Expression e) {
if (!reportTransitions) {
return false;
}
if (e instanceof MethodCallExpr) {
MethodCallExpr methodCallExpr = (MethodCallExpr) e;
String name = methodCallExpr.getName();
if (supportErrorReporting && !name.startsWith("errHtml4")
&& ("stateLoop".equals(currentMethod))
&& (name.startsWith("err") || name.startsWith("maybeErr"))) {
return true;
}
}
return false;
}
private boolean isCompletedCharacterReference(Expression e) {
if (!reportTransitions) {
return false;
}
if (e instanceof MethodCallExpr) {
MethodCallExpr methodCallExpr = (MethodCallExpr) e;
String name = methodCallExpr.getName();
if (name.equals("completedNamedCharacterReference")) {
return true;
}
}
return false;
}
private boolean isDroppedExpression(Expression e) {
if (e instanceof MethodCallExpr) {
MethodCallExpr methodCallExpr = (MethodCallExpr) e;
String name = methodCallExpr.getName();
if (name.startsWith("fatal") || name.startsWith("note")
|| name.startsWith("errHtml4") || name.startsWith("warn")
|| name.startsWith("maybeWarn")) {
return true;
}
if (supportErrorReporting
&& ("stateLoop".equals(currentMethod) && !reportTransitions)
&& (name.startsWith("err") || name.startsWith("maybeErr"))) {
return true;
}
if (name.equals("completedNamedCharacterReference")
&& !reportTransitions) {
if (name.startsWith("fatal") || name.startsWith("err")
|| name.startsWith("warn") || name.startsWith("maybeErr")
|| name.startsWith("maybeWarn") || name.startsWith("note")) {
return true;
}
}
......@@ -1882,16 +1784,9 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
public void visit(SwitchEntryStmt n, LocalSymbolTable arg) {
if (n.getLabel() != null) {
boolean isMenuitem = n.getLabel().toString().equals("MENUITEM");
if (isMenuitem) {
printer.printWithoutIndent("#ifdef ENABLE_VOID_MENUITEM\n");
}
printer.print("case ");
n.getLabel().accept(this, arg);
printer.print(":");
if (isMenuitem) {
printer.printWithoutIndent("\n#endif");
}
} else {
printer.print("default:");
}
......@@ -2130,9 +2025,6 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
}
private boolean isErrorOnlyBlock(Statement elseStmt) {
if (supportErrorReporting) {
return false;
}
if (elseStmt instanceof BlockStmt) {
BlockStmt block = (BlockStmt) elseStmt;
List<Statement> statements = block.getStmts();
......@@ -2158,9 +2050,6 @@ public class CppVisitor extends AnnotationHelperVisitor<LocalSymbolTable> {
}
private boolean isErrorHandlerIf(Expression condition) {
if (supportErrorReporting) {
return false;
}
return condition.toString().indexOf("errorHandler") != -1;
}
......
......@@ -32,6 +32,8 @@ import java.io.Writer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import nu.validator.htmlparser.impl.Tokenizer;
/**
* Applies a workaround that splits the <code>stateLoop</code> method in the
* tokenizer into two methods. This way, each method stays under 8000 bytes in
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment