Bug 554513 - Remove buffer growth limits from the HTML5 parser where the old parser did not have the exact corresponding limits. rs=sicking.

--HG--
extra : rebase_source : d9de246b1e950dc314a9680a0043b29d576e291e
This commit is contained in:
Henri Sivonen 2010-03-26 09:50:21 +02:00
parent f39ab57565
commit d55831dadd
6 changed files with 0 additions and 38 deletions

View File

@ -66,8 +66,6 @@ import org.xml.sax.SAXParseException;
*/
public class Tokenizer implements Locator {
private static final int BUFFER_CLIP_THRESHOLD = 8000;
public static final int DATA = 0;
public static final int RCDATA = 1;
@ -1350,12 +1348,6 @@ public class Tokenizer implements Locator {
private void ensureBufferSpace(int addedLength) throws SAXException {
int newlongStrBufCapacity = longStrBufLen + addedLength;
if (newlongStrBufCapacity > Tokenizer.BUFFER_CLIP_THRESHOLD) {
longStrBuf[0] = '\u2026'; // HORIZONTAL ELLIPSIS
longStrBuf[1] = '\uFFFD'; // REPLACEMENT CHARACTER
longStrBufLen = 2;
newlongStrBufCapacity = 2 + addedLength;
}
if (newlongStrBufCapacity > longStrBuf.length) {
char[] newBuf = new char[newlongStrBufCapacity];
System.arraycopy(longStrBuf, 0, newBuf, 0, longStrBufLen);
@ -1364,12 +1356,6 @@ public class Tokenizer implements Locator {
}
int newStrBufCapacity = strBufLen + addedLength;
if (newStrBufCapacity > Tokenizer.BUFFER_CLIP_THRESHOLD) {
strBuf[0] = '\u2026'; // HORIZONTAL ELLIPSIS
strBuf[1] = '\uFFFD'; // REPLACEMENT CHARACTER
strBufLen = 2;
newStrBufCapacity = 2 + addedLength;
}
if (newStrBufCapacity > strBuf.length) {
char[] newBuf = new char[newStrBufCapacity];
System.arraycopy(strBuf, 0, newBuf, 0, strBufLen);

View File

@ -60,8 +60,6 @@ import org.xml.sax.SAXParseException;
public abstract class TreeBuilder<T> implements TokenHandler,
TreeBuilderState<T> {
public static final int BUFFER_FLUSH_THRESHOLD = 4096;
public static final int STACK_MAX_DEPTH = 200;
// Start dispatch groups
@ -842,10 +840,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
*/
public final void ensureBufferSpace(int addedLength) throws SAXException {
int newCharBufferCapacity = charBufferLen + addedLength;
if (newCharBufferCapacity > TreeBuilder.BUFFER_FLUSH_THRESHOLD) {
flushCharacters();
newCharBufferCapacity = addedLength;
}
if (newCharBufferCapacity > charBuffer.length) {
char[] newBuf = new char[newCharBufferCapacity];
System.arraycopy(charBuffer, 0, newBuf, 0, charBufferLen);

View File

@ -369,12 +369,6 @@ void
nsHtml5Tokenizer::ensureBufferSpace(PRInt32 addedLength)
{
PRInt32 newlongStrBufCapacity = longStrBufLen + addedLength;
if (newlongStrBufCapacity > NS_HTML5TOKENIZER_BUFFER_CLIP_THRESHOLD) {
longStrBuf[0] = 0x2026;
longStrBuf[1] = 0xfffd;
longStrBufLen = 2;
newlongStrBufCapacity = 2 + addedLength;
}
if (newlongStrBufCapacity > longStrBuf.length) {
jArray<PRUnichar,PRInt32> newBuf = jArray<PRUnichar,PRInt32>(newlongStrBufCapacity);
nsHtml5ArrayCopy::arraycopy(longStrBuf, newBuf, longStrBufLen);
@ -382,12 +376,6 @@ nsHtml5Tokenizer::ensureBufferSpace(PRInt32 addedLength)
longStrBuf = newBuf;
}
PRInt32 newStrBufCapacity = strBufLen + addedLength;
if (newStrBufCapacity > NS_HTML5TOKENIZER_BUFFER_CLIP_THRESHOLD) {
strBuf[0] = 0x2026;
strBuf[1] = 0xfffd;
strBufLen = 2;
newStrBufCapacity = 2 + addedLength;
}
if (newStrBufCapacity > strBuf.length) {
jArray<PRUnichar,PRInt32> newBuf = jArray<PRUnichar,PRInt32>(newStrBufCapacity);
nsHtml5ArrayCopy::arraycopy(strBuf, newBuf, strBufLen);

View File

@ -346,7 +346,6 @@ jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::NOSCRIPT_ARR = 0;
jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::NOFRAMES_ARR = 0;
#endif
#define NS_HTML5TOKENIZER_BUFFER_CLIP_THRESHOLD 8000
#define NS_HTML5TOKENIZER_DATA 0
#define NS_HTML5TOKENIZER_RCDATA 1
#define NS_HTML5TOKENIZER_SCRIPT_DATA 2

View File

@ -197,10 +197,6 @@ void
nsHtml5TreeBuilder::ensureBufferSpace(PRInt32 addedLength)
{
PRInt32 newCharBufferCapacity = charBufferLen + addedLength;
if (newCharBufferCapacity > NS_HTML5TREE_BUILDER_BUFFER_FLUSH_THRESHOLD) {
flushCharacters();
newCharBufferCapacity = addedLength;
}
if (newCharBufferCapacity > charBuffer.length) {
jArray<PRUnichar,PRInt32> newBuf = jArray<PRUnichar,PRInt32>(newCharBufferCapacity);
nsHtml5ArrayCopy::arraycopy(charBuffer, newBuf, charBufferLen);

View File

@ -248,7 +248,6 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
jArray<const char*,PRInt32> nsHtml5TreeBuilder::QUIRKY_PUBLIC_IDS = nsnull;
#endif
#define NS_HTML5TREE_BUILDER_BUFFER_FLUSH_THRESHOLD 4096
#define NS_HTML5TREE_BUILDER_STACK_MAX_DEPTH 200
#define NS_HTML5TREE_BUILDER_OTHER 0
#define NS_HTML5TREE_BUILDER_A 1