diff --git a/parser/html/javasrc/Tokenizer.java b/parser/html/javasrc/Tokenizer.java
index 6d7c34915573..0357cd015551 100644
--- a/parser/html/javasrc/Tokenizer.java
+++ b/parser/html/javasrc/Tokenizer.java
@@ -511,8 +511,6 @@ public class Tokenizer implements Locator, Locator2 {
private boolean shouldSuspend;
- private boolean keepBuffer;
-
protected boolean confident;
private int line;
@@ -572,7 +570,6 @@ public class Tokenizer implements Locator, Locator2 {
this.systemIdentifier = null;
this.attributes = null;
this.shouldSuspend = false;
- this.keepBuffer = false;
this.confident = false;
this.line = 0;
// CPPONLY: this.attributeLine = 0;
@@ -635,7 +632,6 @@ public class Tokenizer implements Locator, Locator2 {
// CPPONLY: this.attributes = tokenHandler.HasBuilder() ? new HtmlAttributes(mappingLangToXmlLang) : null;
// CPPONLY: this.newAttributesEachTime = !tokenHandler.HasBuilder();
this.shouldSuspend = false;
- this.keepBuffer = false;
this.confident = false;
this.line = 0;
// CPPONLY: this.attributeLine = 0;
@@ -657,18 +653,6 @@ public class Tokenizer implements Locator, Locator2 {
// CPPONLY: return viewingXmlSource;
// CPPONLY: }
- public void setKeepBuffer(boolean keepBuffer) {
- this.keepBuffer = keepBuffer;
- }
-
- public boolean dropBufferIfLongerThan(int length) {
- if (strBuf.length > length) {
- strBuf = null;
- return true;
- }
- return false;
- }
-
// [NOCPP[
/**
@@ -7241,9 +7225,7 @@ public class Tokenizer implements Locator, Locator2 {
}
public void end() throws SAXException {
- if (!keepBuffer) {
- strBuf = null;
- }
+ strBuf = null;
doctypeName = null;
if (systemIdentifier != null) {
Portability.releaseString(systemIdentifier);
@@ -7433,9 +7415,7 @@ public class Tokenizer implements Locator, Locator2 {
public void initializeWithoutStarting() throws SAXException {
confident = false;
- if (!keepBuffer) {
- strBuf = null;
- }
+ strBuf = null;
line = 1;
// CPPONLY: attributeLine = 1;
// [NOCPP[
diff --git a/parser/html/javasrc/TreeBuilder.java b/parser/html/javasrc/TreeBuilder.java
index c190b7fd2020..f7b70ee0dada 100644
--- a/parser/html/javasrc/TreeBuilder.java
+++ b/parser/html/javasrc/TreeBuilder.java
@@ -436,8 +436,6 @@ public abstract class TreeBuilder implements TokenHandler,
private boolean allowDeclarativeShadowRoots = false;
- private boolean keepBuffer = false;
-
// [NOCPP[
private boolean reportingDoctype = true;
@@ -579,18 +577,6 @@ public abstract class TreeBuilder implements TokenHandler,
// ]NOCPP]
- public void setKeepBuffer(boolean keepBuffer) {
- this.keepBuffer = keepBuffer;
- }
-
- public boolean dropBufferIfLongerThan(int length) {
- if (charBuffer.length > length) {
- charBuffer = null;
- return true;
- }
- return false;
- }
-
@SuppressWarnings("unchecked") public final void startTokenization(Tokenizer self) throws SAXException {
tokenizer = self;
stackNodes = new StackNode[64];
@@ -612,9 +598,7 @@ public abstract class TreeBuilder implements TokenHandler,
// ]NOCPP]
start(fragment);
charBufferLen = 0;
- if (!keepBuffer) {
- charBuffer = null;
- }
+ charBuffer = null;
framesetOk = true;
if (fragment) {
T elt;
@@ -1467,10 +1451,7 @@ public abstract class TreeBuilder implements TokenHandler,
// [NOCPP[
idLocations.clear();
// ]NOCPP]
-
- if (!keepBuffer) {
- charBuffer = null;
- }
+ charBuffer = null;
end();
}
diff --git a/parser/html/nsHtml5StringParser.cpp b/parser/html/nsHtml5StringParser.cpp
index 69e2806ce5eb..5fe2b2e323cb 100644
--- a/parser/html/nsHtml5StringParser.cpp
+++ b/parser/html/nsHtml5StringParser.cpp
@@ -20,11 +20,9 @@ nsHtml5StringParser::nsHtml5StringParser()
mTreeBuilder(new nsHtml5TreeBuilder(mBuilder)),
mTokenizer(new nsHtml5Tokenizer(mTreeBuilder.get(), false)) {
mTokenizer->setInterner(&mAtomTable);
- mTokenizer->setKeepBuffer(true);
- mTreeBuilder->setKeepBuffer(true);
}
-nsHtml5StringParser::~nsHtml5StringParser() { ClearCaches(); }
+nsHtml5StringParser::~nsHtml5StringParser() {}
nsresult nsHtml5StringParser::ParseFragment(
const nsAString& aSourceBuffer, nsIContent* aTargetNode,
@@ -71,31 +69,6 @@ nsresult nsHtml5StringParser::ParseDocument(
aTargetDoc->AllowsDeclarativeShadowRoots());
}
-void nsHtml5StringParser::ClearCaches() {
- mTokenizer->dropBufferIfLongerThan(0);
- mTreeBuilder->dropBufferIfLongerThan(0);
- if (mCacheClearer) {
- mCacheClearer->Disconnect();
- mCacheClearer = nullptr;
- }
-}
-
-void nsHtml5StringParser::TryCache() {
- const int32_t kMaxBuffer = 1024 * 1024;
- bool didDrop = mTokenizer->dropBufferIfLongerThan(kMaxBuffer);
- didDrop |= mTreeBuilder->dropBufferIfLongerThan(kMaxBuffer);
- if (didDrop) {
- return;
- }
-
- if (!mCacheClearer) {
- mCacheClearer = new CacheClearer(this);
- nsCOMPtr runnable = mCacheClearer.get();
- NS_DispatchToMainThreadQueue(runnable.forget(),
- mozilla::EventQueuePriority::Idle);
- }
-}
-
nsresult nsHtml5StringParser::Tokenize(const nsAString& aSourceBuffer,
Document* aDocument,
bool aScriptingEnabledForNoscriptParsing,
@@ -136,10 +109,8 @@ nsresult nsHtml5StringParser::Tokenize(const nsAString& aSourceBuffer,
if (NS_SUCCEEDED(rv)) {
mTokenizer->eof();
}
-
mTokenizer->end();
mBuilder->Finish();
mAtomTable.Clear();
- TryCache();
return rv;
}
diff --git a/parser/html/nsHtml5StringParser.h b/parser/html/nsHtml5StringParser.h
index 8b0203301dc5..1d4140484137 100644
--- a/parser/html/nsHtml5StringParser.h
+++ b/parser/html/nsHtml5StringParser.h
@@ -67,9 +67,6 @@ class nsHtml5StringParser : public nsParserBase {
bool aScriptingEnabledForNoscriptParsing,
bool aDeclarativeShadowRootsAllowed);
- void TryCache();
- void ClearCaches();
-
/**
* The tree operation executor
*/
@@ -89,24 +86,6 @@ class nsHtml5StringParser : public nsParserBase {
* The scoped atom table
*/
nsHtml5AtomTable mAtomTable;
-
- class CacheClearer : public mozilla::Runnable {
- public:
- explicit CacheClearer(nsHtml5StringParser* aParser)
- : Runnable("CacheClearer"), mParser(aParser) {}
- NS_IMETHOD Run() {
- if (mParser) {
- mParser->ClearCaches();
- }
- return NS_OK;
- }
- void Disconnect() { mParser = nullptr; }
-
- private:
- nsHtml5StringParser* mParser;
- };
-
- RefPtr mCacheClearer;
};
#endif // nsHtml5StringParser_h
diff --git a/parser/html/nsHtml5Tokenizer.cpp b/parser/html/nsHtml5Tokenizer.cpp
index 127c0a77fc72..5092bf4bf67b 100644
--- a/parser/html/nsHtml5Tokenizer.cpp
+++ b/parser/html/nsHtml5Tokenizer.cpp
@@ -126,7 +126,6 @@ nsHtml5Tokenizer::nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler,
: nullptr),
newAttributesEachTime(!tokenHandler->HasBuilder()),
shouldSuspend(false),
- keepBuffer(false),
confident(false),
line(0),
attributeLine(0),
@@ -147,18 +146,6 @@ void nsHtml5Tokenizer::initLocation(nsHtml5String newPublicId,
bool nsHtml5Tokenizer::isViewingXmlSource() { return viewingXmlSource; }
-void nsHtml5Tokenizer::setKeepBuffer(bool keepBuffer) {
- this->keepBuffer = keepBuffer;
-}
-
-bool nsHtml5Tokenizer::dropBufferIfLongerThan(int32_t length) {
- if (strBuf.length > length) {
- strBuf = nullptr;
- return true;
- }
- return false;
-}
-
void nsHtml5Tokenizer::setState(int32_t specialTokenizerState) {
this->stateSave = specialTokenizerState;
this->endTagExpectation = nullptr;
@@ -5035,9 +5022,7 @@ void nsHtml5Tokenizer::emitOrAppendOne(const char16_t* val,
}
void nsHtml5Tokenizer::end() {
- if (!keepBuffer) {
- strBuf = nullptr;
- }
+ strBuf = nullptr;
doctypeName = nullptr;
if (systemIdentifier) {
systemIdentifier.Release();
@@ -5163,9 +5148,7 @@ void nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other) {
void nsHtml5Tokenizer::initializeWithoutStarting() {
confident = false;
- if (!keepBuffer) {
- strBuf = nullptr;
- }
+ strBuf = nullptr;
line = 1;
attributeLine = 1;
resetToDataState();
diff --git a/parser/html/nsHtml5Tokenizer.h b/parser/html/nsHtml5Tokenizer.h
index e19570ca3f9a..91c70fc4120b 100644
--- a/parser/html/nsHtml5Tokenizer.h
+++ b/parser/html/nsHtml5Tokenizer.h
@@ -308,7 +308,6 @@ class nsHtml5Tokenizer {
nsHtml5HtmlAttributes* attributes;
bool newAttributesEachTime;
bool shouldSuspend;
- bool keepBuffer;
protected:
bool confident;
@@ -324,8 +323,6 @@ class nsHtml5Tokenizer {
void setInterner(nsHtml5AtomTable* interner);
void initLocation(nsHtml5String newPublicId, nsHtml5String newSystemId);
bool isViewingXmlSource();
- void setKeepBuffer(bool keepBuffer);
- bool dropBufferIfLongerThan(int32_t length);
void setState(int32_t specialTokenizerState);
void setStateAndEndTagExpectation(int32_t specialTokenizerState,
nsHtml5ElementName* endTagExpectation);
diff --git a/parser/html/nsHtml5TreeBuilder.cpp b/parser/html/nsHtml5TreeBuilder.cpp
index 9ef9a519f7cc..26db77865fbc 100644
--- a/parser/html/nsHtml5TreeBuilder.cpp
+++ b/parser/html/nsHtml5TreeBuilder.cpp
@@ -100,18 +100,6 @@ static const char* const QUIRKY_PUBLIC_IDS_DATA[] = {
"-//webtechs//dtd mozilla html//"};
staticJArray nsHtml5TreeBuilder::QUIRKY_PUBLIC_IDS = {
QUIRKY_PUBLIC_IDS_DATA, MOZ_ARRAY_LENGTH(QUIRKY_PUBLIC_IDS_DATA)};
-void nsHtml5TreeBuilder::setKeepBuffer(bool keepBuffer) {
- this->keepBuffer = keepBuffer;
-}
-
-bool nsHtml5TreeBuilder::dropBufferIfLongerThan(int32_t length) {
- if (charBuffer.length > length) {
- charBuffer = nullptr;
- return true;
- }
- return false;
-}
-
void nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self) {
tokenizer = self;
stackNodes = jArray::newJArray(64);
@@ -130,9 +118,7 @@ void nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self) {
headPointer = nullptr;
start(fragment);
charBufferLen = 0;
- if (!keepBuffer) {
- charBuffer = nullptr;
- }
+ charBuffer = nullptr;
framesetOk = true;
if (fragment) {
nsIContentHandle* elt;
@@ -666,9 +652,7 @@ void nsHtml5TreeBuilder::endTokenization() {
stackNodesIdx = 0;
stackNodes = nullptr;
}
- if (!keepBuffer) {
- charBuffer = nullptr;
- }
+ charBuffer = nullptr;
end();
}
diff --git a/parser/html/nsHtml5TreeBuilder.h b/parser/html/nsHtml5TreeBuilder.h
index b48902df355b..d6c4828e7cf9 100644
--- a/parser/html/nsHtml5TreeBuilder.h
+++ b/parser/html/nsHtml5TreeBuilder.h
@@ -315,7 +315,6 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState {
bool quirks;
bool forceNoQuirks;
bool allowDeclarativeShadowRoots;
- bool keepBuffer;
inline nsHtml5ContentCreatorFunction htmlCreator(
mozilla::dom::HTMLContentCreatorFunction htmlCreator) {
nsHtml5ContentCreatorFunction creator;
@@ -331,8 +330,6 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState {
}
public:
- void setKeepBuffer(bool keepBuffer);
- bool dropBufferIfLongerThan(int32_t length);
void startTokenization(nsHtml5Tokenizer* self);
void doctype(nsAtom* name, nsHtml5String publicIdentifier,
nsHtml5String systemIdentifier, bool forceQuirks);
diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h
index be2898157bef..59df6937e295 100644
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -42,7 +42,6 @@ nsHtml5TreeBuilder::nsHtml5TreeBuilder(nsHtml5OplessBuilder* aBuilder)
quirks(false),
forceNoQuirks(false),
allowDeclarativeShadowRoots(false),
- keepBuffer(false),
mBuilder(aBuilder),
mViewSource(nullptr),
mOpSink(nullptr),