summaryrefslogtreecommitdiffstats
path: root/parser/html/nsHtml5ElementName.cpp
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-18 13:20:59 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:34 -0500
commit016a21c414f35e0d1af6ee2ffcc17224aab77637 (patch)
tree900b4fafbbd7d25bd9c605dcf934ad0b4009fdeb /parser/html/nsHtml5ElementName.cpp
parente387308d9b996542565175c7895724c86e24e0dc (diff)
downloadUXP-016a21c414f35e0d1af6ee2ffcc17224aab77637.tar
UXP-016a21c414f35e0d1af6ee2ffcc17224aab77637.tar.gz
UXP-016a21c414f35e0d1af6ee2ffcc17224aab77637.tar.lz
UXP-016a21c414f35e0d1af6ee2ffcc17224aab77637.tar.xz
UXP-016a21c414f35e0d1af6ee2ffcc17224aab77637.zip
Bug 1355769 - Avoid malloc for nsHtml5ElementName when processing a non-interned element name.
HTML Regen. Tag UXP Issue #1344
Diffstat (limited to 'parser/html/nsHtml5ElementName.cpp')
-rw-r--r--parser/html/nsHtml5ElementName.cpp33
1 files changed, 13 insertions, 20 deletions
diff --git a/parser/html/nsHtml5ElementName.cpp b/parser/html/nsHtml5ElementName.cpp
index b75d5db6b..6b829dfe3 100644
--- a/parser/html/nsHtml5ElementName.cpp
+++ b/parser/html/nsHtml5ElementName.cpp
@@ -55,9 +55,7 @@
#include "nsHtml5Portability.h"
#include "nsHtml5ElementName.h"
-#include "nsHtml5ReleasableElementName.h"
-nsHtml5ElementName* nsHtml5ElementName::ELT_NULL_ELEMENT_NAME = nullptr;
int32_t
nsHtml5ElementName::getGroup()
{
@@ -65,9 +63,9 @@ nsHtml5ElementName::getGroup()
}
bool
-nsHtml5ElementName::isCustom()
+nsHtml5ElementName::isInterned()
{
- return (flags & NS_HTML5ELEMENT_NAME_CUSTOM);
+ return !(flags & NS_HTML5ELEMENT_NAME_NOT_INTERNED);
}
nsHtml5ElementName*
@@ -76,12 +74,12 @@ nsHtml5ElementName::elementNameByBuffer(char16_t* buf, int32_t offset, int32_t l
uint32_t hash = nsHtml5ElementName::bufToHash(buf, length);
int32_t index = nsHtml5ElementName::ELEMENT_HASHES.binarySearch(hash);
if (index < 0) {
- return new nsHtml5ReleasableElementName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner));
+ return nullptr;
} else {
nsHtml5ElementName* elementName = nsHtml5ElementName::ELEMENT_NAMES[index];
nsIAtom* name = elementName->name;
if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) {
- return new nsHtml5ReleasableElementName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner));
+ return nullptr;
}
return elementName;
}
@@ -97,29 +95,26 @@ nsHtml5ElementName::nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, in
}
-nsHtml5ElementName::nsHtml5ElementName(nsIAtom* name)
- : name(name),
- camelCaseName(name),
- flags(NS_HTML5TREE_BUILDER_OTHER | NS_HTML5ELEMENT_NAME_CUSTOM)
+nsHtml5ElementName::nsHtml5ElementName()
+ : name(nullptr),
+ camelCaseName(nullptr),
+ flags(NS_HTML5TREE_BUILDER_OTHER | NS_HTML5ELEMENT_NAME_NOT_INTERNED)
{
MOZ_COUNT_CTOR(nsHtml5ElementName);
}
-void
-nsHtml5ElementName::release()
-{
-}
-
nsHtml5ElementName::~nsHtml5ElementName()
{
MOZ_COUNT_DTOR(nsHtml5ElementName);
}
-nsHtml5ElementName*
-nsHtml5ElementName::cloneElementName(nsHtml5AtomTable* interner)
+void
+nsHtml5ElementName::setNameForNonInterned(nsIAtom* name)
{
- return this;
+ this->name = name;
+ this->camelCaseName = name;
+ MOZ_ASSERT(this->flags == (NS_HTML5TREE_BUILDER_OTHER | NS_HTML5ELEMENT_NAME_NOT_INTERNED));
}
nsHtml5ElementName* nsHtml5ElementName::ELT_AND = nullptr;
@@ -526,7 +521,6 @@ staticJArray<int32_t,int32_t> nsHtml5ElementName::ELEMENT_HASHES = { ELEMENT_HAS
void
nsHtml5ElementName::initializeStatics()
{
- ELT_NULL_ELEMENT_NAME = new nsHtml5ElementName(nullptr);
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_ABS = new nsHtml5ElementName(nsHtml5Atoms::abs, nsHtml5Atoms::abs, NS_HTML5TREE_BUILDER_OTHER);
@@ -1329,7 +1323,6 @@ nsHtml5ElementName::initializeStatics()
void
nsHtml5ElementName::releaseStatics()
{
- delete ELT_NULL_ELEMENT_NAME;
delete ELT_AND;
delete ELT_ARG;
delete ELT_ABS;