Bug 1355479 - Flatten attribute storage in the HTML parser to AutoTArray to avoid malloc.

HTML Regen.

Tag UXP Issue #1344
This commit is contained in:
Gaming4JC 2020-01-18 16:08:45 -05:00 • committed by Roy Tam
commit 84ba7ad062
18 changed files with 66 additions and 71 deletions

View file

@ -48,6 +48,9 @@ HTML5_ATOM(address, "address")
HTML5_ATOM(div, "div") HTML5_ATOM(div, "div")
HTML5_ATOM(a, "a") HTML5_ATOM(a, "a")
HTML5_ATOM(nobr, "nobr") HTML5_ATOM(nobr, "nobr")
HTML5_ATOM(name, "name")
HTML5_ATOM(prompt, "prompt")
HTML5_ATOM(action, "action")
HTML5_ATOM(input, "input") HTML5_ATOM(input, "input")
HTML5_ATOM(option, "option") HTML5_ATOM(option, "option")
HTML5_ATOM(ruby, "ruby") HTML5_ATOM(ruby, "ruby")
@ -249,7 +252,6 @@ HTML5_ATOM(linebreak, "linebreak")
HTML5_ATOM(label, "label") HTML5_ATOM(label, "label")
HTML5_ATOM(linethickness, "linethickness") HTML5_ATOM(linethickness, "linethickness")
HTML5_ATOM(mode, "mode") HTML5_ATOM(mode, "mode")
HTML5_ATOM(name, "name")
HTML5_ATOM(noresize, "noresize") HTML5_ATOM(noresize, "noresize")
HTML5_ATOM(onbeforeunload, "onbeforeunload") HTML5_ATOM(onbeforeunload, "onbeforeunload")
HTML5_ATOM(onrepeat, "onrepeat") HTML5_ATOM(onrepeat, "onrepeat")
@ -355,7 +357,6 @@ HTML5_ATOM(pathLength, "pathLength")
HTML5_ATOM(path, "path") HTML5_ATOM(path, "path")
HTML5_ATOM(altimg, "altimg") HTML5_ATOM(altimg, "altimg")
HTML5_ATOM(actiontype, "actiontype") HTML5_ATOM(actiontype, "actiontype")
HTML5_ATOM(action, "action")
HTML5_ATOM(active, "active") HTML5_ATOM(active, "active")
HTML5_ATOM(additive, "additive") HTML5_ATOM(additive, "additive")
HTML5_ATOM(begin, "begin") HTML5_ATOM(begin, "begin")
@ -423,7 +424,6 @@ HTML5_ATOM(frameborder, "frameborder")
HTML5_ATOM(frame, "frame") HTML5_ATOM(frame, "frame")
HTML5_ATOM(framespacing, "framespacing") HTML5_ATOM(framespacing, "framespacing")
HTML5_ATOM(from, "from") HTML5_ATOM(from, "from")
HTML5_ATOM(prompt, "prompt")
HTML5_ATOM(primitiveunits, "primitiveunits") HTML5_ATOM(primitiveunits, "primitiveunits")
HTML5_ATOM(primitiveUnits, "primitiveUnits") HTML5_ATOM(primitiveUnits, "primitiveUnits")
HTML5_ATOM(symmetric, "symmetric") HTML5_ATOM(symmetric, "symmetric")
@ -713,6 +713,7 @@ HTML5_ATOM(verythinmathspace, "verythinmathspace")
HTML5_ATOM(verythickmathspace, "verythickmathspace") HTML5_ATOM(verythickmathspace, "verythickmathspace")
HTML5_ATOM(veryverythinmathspace, "veryverythinmathspace") HTML5_ATOM(veryverythinmathspace, "veryverythinmathspace")
HTML5_ATOM(veryverythickmathspace, "veryverythickmathspace") HTML5_ATOM(veryverythickmathspace, "veryverythickmathspace")
HTML5_ATOM(isindex, "isindex")
HTML5_ATOM(and_, "and") HTML5_ATOM(and_, "and")
HTML5_ATOM(arg, "arg") HTML5_ATOM(arg, "arg")
HTML5_ATOM(abs, "abs") HTML5_ATOM(abs, "abs")
@ -1066,7 +1067,6 @@ HTML5_ATOM(fecolormatrix, "fecolormatrix")
HTML5_ATOM(feColorMatrix, "feColorMatrix") HTML5_ATOM(feColorMatrix, "feColorMatrix")
HTML5_ATOM(feconvolvematrix, "feconvolvematrix") HTML5_ATOM(feconvolvematrix, "feconvolvematrix")
HTML5_ATOM(feConvolveMatrix, "feConvolveMatrix") HTML5_ATOM(feConvolveMatrix, "feConvolveMatrix")
HTML5_ATOM(isindex, "isindex")
HTML5_ATOM(matrix, "matrix") HTML5_ATOM(matrix, "matrix")
HTML5_ATOM(apply, "apply") HTML5_ATOM(apply, "apply")
HTML5_ATOM(femorphology, "femorphology") HTML5_ATOM(femorphology, "femorphology")

View file

@ -48,14 +48,12 @@
#include "nsHtml5TreeBuilder.h" #include "nsHtml5TreeBuilder.h"
#include "nsHtml5MetaScanner.h" #include "nsHtml5MetaScanner.h"
#include "nsHtml5ElementName.h" #include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5StackNode.h" #include "nsHtml5StackNode.h"
#include "nsHtml5UTF16Buffer.h" #include "nsHtml5UTF16Buffer.h"
#include "nsHtml5StateSnapshot.h" #include "nsHtml5StateSnapshot.h"
#include "nsHtml5Portability.h" #include "nsHtml5Portability.h"
#include "nsHtml5AttributeName.h" #include "nsHtml5AttributeName.h"
#include "nsHtml5ReleasableAttributeName.h"
int32_t* nsHtml5AttributeName::ALL_NO_NS = 0; int32_t* nsHtml5AttributeName::ALL_NO_NS = 0;
int32_t* nsHtml5AttributeName::XMLNS_NS = 0; int32_t* nsHtml5AttributeName::XMLNS_NS = 0;
@ -111,35 +109,55 @@ nsHtml5AttributeName::nameByBuffer(char16_t* buf, int32_t offset, int32_t length
uint32_t hash = nsHtml5AttributeName::bufToHash(buf, length); uint32_t hash = nsHtml5AttributeName::bufToHash(buf, length);
int32_t index = nsHtml5AttributeName::ATTRIBUTE_HASHES.binarySearch(hash); int32_t index = nsHtml5AttributeName::ATTRIBUTE_HASHES.binarySearch(hash);
if (index < 0) { if (index < 0) {
return nsHtml5AttributeName::createAttributeName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner)); return nullptr;
} else { }
nsHtml5AttributeName* attributeName = nsHtml5AttributeName::ATTRIBUTE_NAMES[index]; nsHtml5AttributeName* attributeName = nsHtml5AttributeName::ATTRIBUTE_NAMES[index];
nsIAtom* name = attributeName->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML); nsIAtom* name = attributeName->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML);
if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) { if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) {
return nsHtml5AttributeName::createAttributeName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner)); return nullptr;
} }
return attributeName; return attributeName;
} }
}
nsHtml5AttributeName::nsHtml5AttributeName(int32_t* uri, nsIAtom** local, nsIAtom** prefix) nsHtml5AttributeName::nsHtml5AttributeName(int32_t* uri, nsIAtom** local, nsIAtom** prefix)
: uri(uri), : uri(uri),
local(local), local(local),
prefix(prefix) prefix(prefix),
custom(false)
{ {
MOZ_COUNT_CTOR(nsHtml5AttributeName); MOZ_COUNT_CTOR(nsHtml5AttributeName);
} }
nsHtml5AttributeName::nsHtml5AttributeName()
: uri(nsHtml5AttributeName::ALL_NO_NS),
local(nsHtml5AttributeName::SAME_LOCAL(nullptr)),
prefix(ALL_NO_PREFIX),
custom(true)
{
MOZ_COUNT_CTOR(nsHtml5AttributeName);
}
bool
nsHtml5AttributeName::isInterned()
{
return !custom;
}
void
nsHtml5AttributeName::setNameForNonInterned(nsIAtom* name)
{
MOZ_ASSERT(custom);
local[0] = name;
local[1] = name;
local[2] = name;
}
nsHtml5AttributeName* nsHtml5AttributeName*
nsHtml5AttributeName::createAttributeName(nsIAtom* name) nsHtml5AttributeName::createAttributeName(nsIAtom* name)
{ {
return new nsHtml5ReleasableAttributeName(nsHtml5AttributeName::ALL_NO_NS, nsHtml5AttributeName::SAME_LOCAL(name), ALL_NO_PREFIX); return new nsHtml5AttributeName(nsHtml5AttributeName::ALL_NO_NS, nsHtml5AttributeName::SAME_LOCAL(name), ALL_NO_PREFIX);
}
void
nsHtml5AttributeName::release()
{
} }
@ -149,12 +167,6 @@ nsHtml5AttributeName::~nsHtml5AttributeName()
delete[] local; delete[] local;
} }
nsHtml5AttributeName*
nsHtml5AttributeName::cloneAttributeName(nsHtml5AtomTable* interner)
{
return this;
}
int32_t int32_t
nsHtml5AttributeName::getUri(int32_t mode) nsHtml5AttributeName::getUri(int32_t mode)
{ {

View file

@ -51,7 +51,6 @@ class nsHtml5Tokenizer;
class nsHtml5TreeBuilder; class nsHtml5TreeBuilder;
class nsHtml5MetaScanner; class nsHtml5MetaScanner;
class nsHtml5ElementName; class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer; class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot; class nsHtml5StateSnapshot;
class nsHtml5Portability; class nsHtml5Portability;
@ -114,14 +113,14 @@ class nsHtml5AttributeName
int32_t* uri; int32_t* uri;
nsIAtom** local; nsIAtom** local;
nsIAtom** prefix; nsIAtom** prefix;
protected: bool custom;
nsHtml5AttributeName(int32_t* uri, nsIAtom** local, nsIAtom** prefix); nsHtml5AttributeName(int32_t* uri, nsIAtom** local, nsIAtom** prefix);
private:
static nsHtml5AttributeName* createAttributeName(nsIAtom* name);
public: public:
virtual void release(); nsHtml5AttributeName();
virtual ~nsHtml5AttributeName(); bool isInterned();
virtual nsHtml5AttributeName* cloneAttributeName(nsHtml5AtomTable* interner); void setNameForNonInterned(nsIAtom* name);
static nsHtml5AttributeName* createAttributeName(nsIAtom* name);
~nsHtml5AttributeName();
int32_t getUri(int32_t mode); int32_t getUri(int32_t mode);
nsIAtom* getLocal(int32_t mode); nsIAtom* getLocal(int32_t mode);
nsIAtom* getPrefix(int32_t mode); nsIAtom* getPrefix(int32_t mode);

View file

@ -48,7 +48,6 @@
#include "nsHtml5TreeBuilder.h" #include "nsHtml5TreeBuilder.h"
#include "nsHtml5MetaScanner.h" #include "nsHtml5MetaScanner.h"
#include "nsHtml5AttributeName.h" #include "nsHtml5AttributeName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5StackNode.h" #include "nsHtml5StackNode.h"
#include "nsHtml5UTF16Buffer.h" #include "nsHtml5UTF16Buffer.h"
#include "nsHtml5StateSnapshot.h" #include "nsHtml5StateSnapshot.h"
@ -117,6 +116,7 @@ nsHtml5ElementName::setNameForNonInterned(nsIAtom* name)
MOZ_ASSERT(this->flags == (NS_HTML5TREE_BUILDER_OTHER | NS_HTML5ELEMENT_NAME_NOT_INTERNED)); MOZ_ASSERT(this->flags == (NS_HTML5TREE_BUILDER_OTHER | NS_HTML5ELEMENT_NAME_NOT_INTERNED));
} }
nsHtml5ElementName* nsHtml5ElementName::ELT_ISINDEX = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_AND = nullptr; nsHtml5ElementName* nsHtml5ElementName::ELT_AND = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_ARG = nullptr; nsHtml5ElementName* nsHtml5ElementName::ELT_ARG = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_ABS = nullptr; nsHtml5ElementName* nsHtml5ElementName::ELT_ABS = nullptr;
@ -505,7 +505,6 @@ nsHtml5ElementName* nsHtml5ElementName::ELT_VIEW = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_APPROX = nullptr; nsHtml5ElementName* nsHtml5ElementName::ELT_APPROX = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_FECOLORMATRIX = nullptr; nsHtml5ElementName* nsHtml5ElementName::ELT_FECOLORMATRIX = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_FECONVOLVEMATRIX = nullptr; nsHtml5ElementName* nsHtml5ElementName::ELT_FECONVOLVEMATRIX = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_ISINDEX = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_MATRIX = nullptr; nsHtml5ElementName* nsHtml5ElementName::ELT_MATRIX = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_APPLY = nullptr; nsHtml5ElementName* nsHtml5ElementName::ELT_APPLY = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_BODY = nullptr; nsHtml5ElementName* nsHtml5ElementName::ELT_BODY = nullptr;
@ -521,6 +520,7 @@ staticJArray<int32_t,int32_t> nsHtml5ElementName::ELEMENT_HASHES = { ELEMENT_HAS
void void
nsHtml5ElementName::initializeStatics() nsHtml5ElementName::initializeStatics()
{ {
ELT_ISINDEX = new nsHtml5ElementName(nsHtml5Atoms::isindex, nsHtml5Atoms::isindex, NS_HTML5TREE_BUILDER_ISINDEX | NS_HTML5ELEMENT_NAME_SPECIAL);
ELT_AND = new nsHtml5ElementName(nsHtml5Atoms::and_, nsHtml5Atoms::and_, NS_HTML5TREE_BUILDER_OTHER); ELT_AND = new nsHtml5ElementName(nsHtml5Atoms::and_, nsHtml5Atoms::and_, NS_HTML5TREE_BUILDER_OTHER);
ELT_ARG = new nsHtml5ElementName(nsHtml5Atoms::arg, nsHtml5Atoms::arg, NS_HTML5TREE_BUILDER_OTHER); ELT_ARG = new nsHtml5ElementName(nsHtml5Atoms::arg, nsHtml5Atoms::arg, NS_HTML5TREE_BUILDER_OTHER);
ELT_ABS = new nsHtml5ElementName(nsHtml5Atoms::abs, nsHtml5Atoms::abs, NS_HTML5TREE_BUILDER_OTHER); ELT_ABS = new nsHtml5ElementName(nsHtml5Atoms::abs, nsHtml5Atoms::abs, NS_HTML5TREE_BUILDER_OTHER);
@ -909,7 +909,6 @@ nsHtml5ElementName::initializeStatics()
ELT_APPROX = new nsHtml5ElementName(nsHtml5Atoms::approx, nsHtml5Atoms::approx, NS_HTML5TREE_BUILDER_OTHER); ELT_APPROX = new nsHtml5ElementName(nsHtml5Atoms::approx, nsHtml5Atoms::approx, NS_HTML5TREE_BUILDER_OTHER);
ELT_FECOLORMATRIX = new nsHtml5ElementName(nsHtml5Atoms::fecolormatrix, nsHtml5Atoms::feColorMatrix, NS_HTML5TREE_BUILDER_OTHER); ELT_FECOLORMATRIX = new nsHtml5ElementName(nsHtml5Atoms::fecolormatrix, nsHtml5Atoms::feColorMatrix, NS_HTML5TREE_BUILDER_OTHER);
ELT_FECONVOLVEMATRIX = new nsHtml5ElementName(nsHtml5Atoms::feconvolvematrix, nsHtml5Atoms::feConvolveMatrix, NS_HTML5TREE_BUILDER_OTHER); ELT_FECONVOLVEMATRIX = new nsHtml5ElementName(nsHtml5Atoms::feconvolvematrix, nsHtml5Atoms::feConvolveMatrix, NS_HTML5TREE_BUILDER_OTHER);
ELT_ISINDEX = new nsHtml5ElementName(nsHtml5Atoms::isindex, nsHtml5Atoms::isindex, NS_HTML5TREE_BUILDER_ISINDEX | NS_HTML5ELEMENT_NAME_SPECIAL);
ELT_MATRIX = new nsHtml5ElementName(nsHtml5Atoms::matrix, nsHtml5Atoms::matrix, NS_HTML5TREE_BUILDER_OTHER); ELT_MATRIX = new nsHtml5ElementName(nsHtml5Atoms::matrix, nsHtml5Atoms::matrix, NS_HTML5TREE_BUILDER_OTHER);
ELT_APPLY = new nsHtml5ElementName(nsHtml5Atoms::apply, nsHtml5Atoms::apply, NS_HTML5TREE_BUILDER_OTHER); ELT_APPLY = new nsHtml5ElementName(nsHtml5Atoms::apply, nsHtml5Atoms::apply, NS_HTML5TREE_BUILDER_OTHER);
ELT_BODY = new nsHtml5ElementName(nsHtml5Atoms::body, nsHtml5Atoms::body, NS_HTML5TREE_BUILDER_BODY | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG); ELT_BODY = new nsHtml5ElementName(nsHtml5Atoms::body, nsHtml5Atoms::body, NS_HTML5TREE_BUILDER_BODY | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
@ -1323,6 +1322,7 @@ nsHtml5ElementName::initializeStatics()
void void
nsHtml5ElementName::releaseStatics() nsHtml5ElementName::releaseStatics()
{ {
delete ELT_ISINDEX;
delete ELT_AND; delete ELT_AND;
delete ELT_ARG; delete ELT_ARG;
delete ELT_ABS; delete ELT_ABS;
@ -1711,7 +1711,6 @@ nsHtml5ElementName::releaseStatics()
delete ELT_APPROX; delete ELT_APPROX;
delete ELT_FECOLORMATRIX; delete ELT_FECOLORMATRIX;
delete ELT_FECONVOLVEMATRIX; delete ELT_FECONVOLVEMATRIX;
delete ELT_ISINDEX;
delete ELT_MATRIX; delete ELT_MATRIX;
delete ELT_APPLY; delete ELT_APPLY;
delete ELT_BODY; delete ELT_BODY;

View file

@ -51,7 +51,6 @@ class nsHtml5Tokenizer;
class nsHtml5TreeBuilder; class nsHtml5TreeBuilder;
class nsHtml5MetaScanner; class nsHtml5MetaScanner;
class nsHtml5AttributeName; class nsHtml5AttributeName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer; class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot; class nsHtml5StateSnapshot;
class nsHtml5Portability; class nsHtml5Portability;
@ -118,6 +117,7 @@ class nsHtml5ElementName
nsHtml5ElementName(); nsHtml5ElementName();
~nsHtml5ElementName(); ~nsHtml5ElementName();
void setNameForNonInterned(nsIAtom* name); void setNameForNonInterned(nsIAtom* name);
static nsHtml5ElementName* ELT_ISINDEX;
static nsHtml5ElementName* ELT_AND; static nsHtml5ElementName* ELT_AND;
static nsHtml5ElementName* ELT_ARG; static nsHtml5ElementName* ELT_ARG;
static nsHtml5ElementName* ELT_ABS; static nsHtml5ElementName* ELT_ABS;
@ -506,7 +506,6 @@ class nsHtml5ElementName
static nsHtml5ElementName* ELT_APPROX; static nsHtml5ElementName* ELT_APPROX;
static nsHtml5ElementName* ELT_FECOLORMATRIX; static nsHtml5ElementName* ELT_FECOLORMATRIX;
static nsHtml5ElementName* ELT_FECONVOLVEMATRIX; static nsHtml5ElementName* ELT_FECONVOLVEMATRIX;
static nsHtml5ElementName* ELT_ISINDEX;
static nsHtml5ElementName* ELT_MATRIX; static nsHtml5ElementName* ELT_MATRIX;
static nsHtml5ElementName* ELT_APPLY; static nsHtml5ElementName* ELT_APPLY;
static nsHtml5ElementName* ELT_BODY; static nsHtml5ElementName* ELT_BODY;

View file

@ -49,7 +49,6 @@
#include "nsHtml5TreeBuilder.h" #include "nsHtml5TreeBuilder.h"
#include "nsHtml5AttributeName.h" #include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h" #include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5StackNode.h" #include "nsHtml5StackNode.h"
#include "nsHtml5UTF16Buffer.h" #include "nsHtml5UTF16Buffer.h"
#include "nsHtml5StateSnapshot.h" #include "nsHtml5StateSnapshot.h"

View file

@ -52,7 +52,6 @@ class nsHtml5Tokenizer;
class nsHtml5TreeBuilder; class nsHtml5TreeBuilder;
class nsHtml5AttributeName; class nsHtml5AttributeName;
class nsHtml5ElementName; class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer; class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot; class nsHtml5StateSnapshot;
class nsHtml5Portability; class nsHtml5Portability;

View file

@ -52,7 +52,6 @@ class nsHtml5TreeBuilder;
class nsHtml5MetaScanner; class nsHtml5MetaScanner;
class nsHtml5AttributeName; class nsHtml5AttributeName;
class nsHtml5ElementName; class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer; class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot; class nsHtml5StateSnapshot;

View file

@ -50,7 +50,6 @@
#include "nsHtml5MetaScanner.h" #include "nsHtml5MetaScanner.h"
#include "nsHtml5AttributeName.h" #include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h" #include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5UTF16Buffer.h" #include "nsHtml5UTF16Buffer.h"
#include "nsHtml5StateSnapshot.h" #include "nsHtml5StateSnapshot.h"
#include "nsHtml5Portability.h" #include "nsHtml5Portability.h"

View file

@ -53,7 +53,6 @@ class nsHtml5TreeBuilder;
class nsHtml5MetaScanner; class nsHtml5MetaScanner;
class nsHtml5AttributeName; class nsHtml5AttributeName;
class nsHtml5ElementName; class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer; class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot; class nsHtml5StateSnapshot;
class nsHtml5Portability; class nsHtml5Portability;

View file

@ -49,7 +49,6 @@
#include "nsHtml5MetaScanner.h" #include "nsHtml5MetaScanner.h"
#include "nsHtml5AttributeName.h" #include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h" #include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5StackNode.h" #include "nsHtml5StackNode.h"
#include "nsHtml5UTF16Buffer.h" #include "nsHtml5UTF16Buffer.h"
#include "nsHtml5Portability.h" #include "nsHtml5Portability.h"

View file

@ -52,7 +52,6 @@ class nsHtml5TreeBuilder;
class nsHtml5MetaScanner; class nsHtml5MetaScanner;
class nsHtml5AttributeName; class nsHtml5AttributeName;
class nsHtml5ElementName; class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer; class nsHtml5UTF16Buffer;
class nsHtml5Portability; class nsHtml5Portability;

View file

@ -52,7 +52,6 @@
#include "nsHtml5MetaScanner.h" #include "nsHtml5MetaScanner.h"
#include "nsHtml5AttributeName.h" #include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h" #include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5StackNode.h" #include "nsHtml5StackNode.h"
#include "nsHtml5UTF16Buffer.h" #include "nsHtml5UTF16Buffer.h"
#include "nsHtml5StateSnapshot.h" #include "nsHtml5StateSnapshot.h"
@ -99,6 +98,7 @@ nsHtml5Tokenizer::nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewin
tagName(nullptr), tagName(nullptr),
nonInternedTagName(new nsHtml5ElementName()), nonInternedTagName(new nsHtml5ElementName()),
attributeName(nullptr), attributeName(nullptr),
nonInternedAttributeName(new nsHtml5AttributeName()),
doctypeName(nullptr), doctypeName(nullptr),
publicIdentifier(nullptr), publicIdentifier(nullptr),
systemIdentifier(nullptr), systemIdentifier(nullptr),
@ -325,13 +325,16 @@ void
nsHtml5Tokenizer::attributeNameComplete() nsHtml5Tokenizer::attributeNameComplete()
{ {
attributeName = nsHtml5AttributeName::nameByBuffer(strBuf, 0, strBufLen, interner); attributeName = nsHtml5AttributeName::nameByBuffer(strBuf, 0, strBufLen, interner);
if (!attributeName) {
nonInternedAttributeName->setNameForNonInterned(nsHtml5Portability::newLocalNameFromBuffer(strBuf, 0, strBufLen, interner));
attributeName = nonInternedAttributeName;
}
clearStrBufAfterUse(); clearStrBufAfterUse();
if (!attributes) { if (!attributes) {
attributes = new nsHtml5HtmlAttributes(0); attributes = new nsHtml5HtmlAttributes(0);
} }
if (attributes->contains(attributeName)) { if (attributes->contains(attributeName)) {
errDuplicateAttribute(); errDuplicateAttribute();
attributeName->release();
attributeName = nullptr; attributeName = nullptr;
} }
} }
@ -3941,10 +3944,8 @@ nsHtml5Tokenizer::end()
} }
tagName = nullptr; tagName = nullptr;
nonInternedTagName->setNameForNonInterned(nullptr); nonInternedTagName->setNameForNonInterned(nullptr);
if (attributeName) {
attributeName->release();
attributeName = nullptr; attributeName = nullptr;
} nonInternedAttributeName->setNameForNonInterned(nullptr);
tokenHandler->endTokenization(); tokenHandler->endTokenization();
if (attributes) { if (attributes) {
attributes->clear(0); attributes->clear(0);
@ -3984,13 +3985,8 @@ nsHtml5Tokenizer::resetToDataState()
endTag = false; endTag = false;
shouldSuspend = false; shouldSuspend = false;
initDoctypeFields(); initDoctypeFields();
if (tagName) {
tagName = nullptr; tagName = nullptr;
}
if (attributeName) {
attributeName->release();
attributeName = nullptr; attributeName = nullptr;
}
if (newAttributesEachTime) { if (newAttributesEachTime) {
if (attributes) { if (attributes) {
delete attributes; delete attributes;
@ -4052,13 +4048,13 @@ nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other)
nonInternedTagName->setNameForNonInterned(nsHtml5Portability::newLocalFromLocal(other->tagName->getName(), interner)); nonInternedTagName->setNameForNonInterned(nsHtml5Portability::newLocalFromLocal(other->tagName->getName(), interner));
tagName = nonInternedTagName; tagName = nonInternedTagName;
} }
if (attributeName) {
attributeName->release();
}
if (!other->attributeName) { if (!other->attributeName) {
attributeName = nullptr; attributeName = nullptr;
} else if (other->attributeName->isInterned()) {
attributeName = other->attributeName;
} else { } else {
attributeName = other->attributeName->cloneAttributeName(interner); nonInternedAttributeName->setNameForNonInterned(nsHtml5Portability::newLocalFromLocal(other->attributeName->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML), interner));
attributeName = nonInternedAttributeName;
} }
delete attributes; delete attributes;
if (!other->attributes) { if (!other->attributes) {
@ -4089,6 +4085,7 @@ nsHtml5Tokenizer::~nsHtml5Tokenizer()
{ {
MOZ_COUNT_DTOR(nsHtml5Tokenizer); MOZ_COUNT_DTOR(nsHtml5Tokenizer);
delete nonInternedTagName; delete nonInternedTagName;
delete nonInternedAttributeName;
nonInternedTagName = nullptr; nonInternedTagName = nullptr;
delete attributes; delete attributes;
attributes = nullptr; attributes = nullptr;

View file

@ -55,7 +55,6 @@ class nsHtml5TreeBuilder;
class nsHtml5MetaScanner; class nsHtml5MetaScanner;
class nsHtml5AttributeName; class nsHtml5AttributeName;
class nsHtml5ElementName; class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer; class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot; class nsHtml5StateSnapshot;
class nsHtml5Portability; class nsHtml5Portability;
@ -128,6 +127,7 @@ class nsHtml5Tokenizer
protected: protected:
nsHtml5AttributeName* attributeName; nsHtml5AttributeName* attributeName;
private: private:
nsHtml5AttributeName* nonInternedAttributeName;
nsIAtom* doctypeName; nsIAtom* doctypeName;
nsHtml5String publicIdentifier; nsHtml5String publicIdentifier;
nsHtml5String systemIdentifier; nsHtml5String systemIdentifier;

View file

@ -62,7 +62,6 @@
#include "nsHtml5MetaScanner.h" #include "nsHtml5MetaScanner.h"
#include "nsHtml5AttributeName.h" #include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h" #include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5StackNode.h" #include "nsHtml5StackNode.h"
#include "nsHtml5UTF16Buffer.h" #include "nsHtml5UTF16Buffer.h"
#include "nsHtml5StateSnapshot.h" #include "nsHtml5StateSnapshot.h"
@ -1260,11 +1259,11 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
nsHtml5HtmlAttributes* inputAttributes = new nsHtml5HtmlAttributes(0); nsHtml5HtmlAttributes* inputAttributes = new nsHtml5HtmlAttributes(0);
inputAttributes->addAttribute(nsHtml5AttributeName::ATTR_NAME, nsHtml5Portability::newStringFromLiteral("isindex"), tokenizer->getLineNumber()); inputAttributes->addAttribute(nsHtml5AttributeName::ATTR_NAME, nsHtml5Portability::newStringFromLiteral("isindex"), tokenizer->getLineNumber());
for (int32_t i = 0; i < attributes->getLength(); i++) { for (int32_t i = 0; i < attributes->getLength(); i++) {
nsHtml5AttributeName* attributeQName = attributes->getAttributeNameNoBoundsCheck(i); nsIAtom* attributeQName = attributes->getLocalNameNoBoundsCheck(i);
if (nsHtml5AttributeName::ATTR_NAME == attributeQName || nsHtml5AttributeName::ATTR_PROMPT == attributeQName) { if (nsHtml5Atoms::name == attributeQName || nsHtml5Atoms::prompt == attributeQName) {
attributes->releaseValue(i); attributes->releaseValue(i);
} else if (nsHtml5AttributeName::ATTR_ACTION != attributeQName) { } else if (nsHtml5Atoms::action != attributeQName) {
inputAttributes->addAttribute(attributeQName, attributes->getValueNoBoundsCheck(i), attributes->getLineNoBoundsCheck(i)); inputAttributes->AddAttributeWithLocal(attributeQName, attributes->getValueNoBoundsCheck(i), attributes->getLineNoBoundsCheck(i));
} }
} }
attributes->clearWithoutReleasingContents(); attributes->clearWithoutReleasingContents();

View file

@ -65,7 +65,6 @@ class nsHtml5Tokenizer;
class nsHtml5MetaScanner; class nsHtml5MetaScanner;
class nsHtml5AttributeName; class nsHtml5AttributeName;
class nsHtml5ElementName; class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer; class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot; class nsHtml5StateSnapshot;
class nsHtml5Portability; class nsHtml5Portability;

View file

@ -49,7 +49,6 @@
#include "nsHtml5MetaScanner.h" #include "nsHtml5MetaScanner.h"
#include "nsHtml5AttributeName.h" #include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h" #include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5StackNode.h" #include "nsHtml5StackNode.h"
#include "nsHtml5StateSnapshot.h" #include "nsHtml5StateSnapshot.h"
#include "nsHtml5Portability.h" #include "nsHtml5Portability.h"

View file

@ -52,7 +52,6 @@ class nsHtml5TreeBuilder;
class nsHtml5MetaScanner; class nsHtml5MetaScanner;
class nsHtml5AttributeName; class nsHtml5AttributeName;
class nsHtml5ElementName; class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5StateSnapshot; class nsHtml5StateSnapshot;
class nsHtml5Portability; class nsHtml5Portability;