summaryrefslogtreecommitdiffstats
path: root/parser/html/nsHtml5Tokenizer.cpp
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-18 16:08:45 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:36 -0500
commite5557d43d6934918c018a527f3bae1f7049b9ef1 (patch)
treeff494bb15bd1031f8c5b3a2d6550f6d9b5304e33 /parser/html/nsHtml5Tokenizer.cpp
parent650f6b5eb31dfe6c60da16d1498f8cc3efac4dfa (diff)
downloadUXP-e5557d43d6934918c018a527f3bae1f7049b9ef1.tar
UXP-e5557d43d6934918c018a527f3bae1f7049b9ef1.tar.gz
UXP-e5557d43d6934918c018a527f3bae1f7049b9ef1.tar.lz
UXP-e5557d43d6934918c018a527f3bae1f7049b9ef1.tar.xz
UXP-e5557d43d6934918c018a527f3bae1f7049b9ef1.zip
Bug 1355479 - Flatten attribute storage in the HTML parser to AutoTArray to avoid malloc.
HTML Regen. Tag UXP Issue #1344
Diffstat (limited to 'parser/html/nsHtml5Tokenizer.cpp')
-rw-r--r--parser/html/nsHtml5Tokenizer.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/parser/html/nsHtml5Tokenizer.cpp b/parser/html/nsHtml5Tokenizer.cpp
index aa5b3df28..3b1c34b58 100644
--- a/parser/html/nsHtml5Tokenizer.cpp
+++ b/parser/html/nsHtml5Tokenizer.cpp
@@ -52,7 +52,6 @@
#include "nsHtml5MetaScanner.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
-#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5StackNode.h"
#include "nsHtml5UTF16Buffer.h"
#include "nsHtml5StateSnapshot.h"
@@ -99,6 +98,7 @@ nsHtml5Tokenizer::nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewin
tagName(nullptr),
nonInternedTagName(new nsHtml5ElementName()),
attributeName(nullptr),
+ nonInternedAttributeName(new nsHtml5AttributeName()),
doctypeName(nullptr),
publicIdentifier(nullptr),
systemIdentifier(nullptr),
@@ -325,13 +325,16 @@ void
nsHtml5Tokenizer::attributeNameComplete()
{
attributeName = nsHtml5AttributeName::nameByBuffer(strBuf, 0, strBufLen, interner);
+ if (!attributeName) {
+ nonInternedAttributeName->setNameForNonInterned(nsHtml5Portability::newLocalNameFromBuffer(strBuf, 0, strBufLen, interner));
+ attributeName = nonInternedAttributeName;
+ }
clearStrBufAfterUse();
if (!attributes) {
attributes = new nsHtml5HtmlAttributes(0);
}
if (attributes->contains(attributeName)) {
errDuplicateAttribute();
- attributeName->release();
attributeName = nullptr;
}
}
@@ -3941,10 +3944,8 @@ nsHtml5Tokenizer::end()
}
tagName = nullptr;
nonInternedTagName->setNameForNonInterned(nullptr);
- if (attributeName) {
- attributeName->release();
- attributeName = nullptr;
- }
+ attributeName = nullptr;
+ nonInternedAttributeName->setNameForNonInterned(nullptr);
tokenHandler->endTokenization();
if (attributes) {
attributes->clear(0);
@@ -3984,13 +3985,8 @@ nsHtml5Tokenizer::resetToDataState()
endTag = false;
shouldSuspend = false;
initDoctypeFields();
- if (tagName) {
- tagName = nullptr;
- }
- if (attributeName) {
- attributeName->release();
- attributeName = nullptr;
- }
+ tagName = nullptr;
+ attributeName = nullptr;
if (newAttributesEachTime) {
if (attributes) {
delete attributes;
@@ -4052,13 +4048,13 @@ nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other)
nonInternedTagName->setNameForNonInterned(nsHtml5Portability::newLocalFromLocal(other->tagName->getName(), interner));
tagName = nonInternedTagName;
}
- if (attributeName) {
- attributeName->release();
- }
if (!other->attributeName) {
attributeName = nullptr;
+ } else if (other->attributeName->isInterned()) {
+ attributeName = other->attributeName;
} else {
- attributeName = other->attributeName->cloneAttributeName(interner);
+ nonInternedAttributeName->setNameForNonInterned(nsHtml5Portability::newLocalFromLocal(other->attributeName->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML), interner));
+ attributeName = nonInternedAttributeName;
}
delete attributes;
if (!other->attributes) {
@@ -4089,6 +4085,7 @@ nsHtml5Tokenizer::~nsHtml5Tokenizer()
{
MOZ_COUNT_DTOR(nsHtml5Tokenizer);
delete nonInternedTagName;
+ delete nonInternedAttributeName;
nonInternedTagName = nullptr;
delete attributes;
attributes = nullptr;