Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1063)

Unified Diff: Source/core/html/parser/HTMLTreeBuilder.cpp

Issue 51983003: Stop using static arrays for *Tags / *Attrs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/parser/HTMLTreeBuilder.cpp
diff --git a/Source/core/html/parser/HTMLTreeBuilder.cpp b/Source/core/html/parser/HTMLTreeBuilder.cpp
index f419b65ae001cf190ff2e9431402cd2c25a8af32..8b31d8d689f4122ae1c8b86d335a3e0aa1f8d14f 100644
--- a/Source/core/html/parser/HTMLTreeBuilder.cpp
+++ b/Source/core/html/parser/HTMLTreeBuilder.cpp
@@ -549,8 +549,9 @@ void HTMLTreeBuilder::processCloseWhenNestedTag(AtomicHTMLToken* token)
typedef HashMap<AtomicString, QualifiedName> PrefixedNameToQualifiedNameMap;
-static void mapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map, const QualifiedName* const* names, size_t length)
+static void mapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map, const Vector<const QualifiedName*>& names)
{
+ size_t length = names.size();
for (size_t i = 0; i < length; ++i) {
const QualifiedName& name = *names[i];
const AtomicString& localName = name.localName();
@@ -565,8 +566,9 @@ static void adjustSVGTagNameCase(AtomicHTMLToken* token)
static PrefixedNameToQualifiedNameMap* caseMap = 0;
if (!caseMap) {
caseMap = new PrefixedNameToQualifiedNameMap;
- const QualifiedName* const* svgTags = SVGNames::getSVGTags();
- mapLoweredLocalNameToName(caseMap, svgTags, SVGNames::SVGTagsCount);
+ Vector<const QualifiedName*> svgTags;
+ SVGNames::getSVGTags(svgTags);
+ mapLoweredLocalNameToName(caseMap, svgTags);
}
const QualifiedName& casedName = caseMap->get(token->name());
@@ -575,14 +577,15 @@ static void adjustSVGTagNameCase(AtomicHTMLToken* token)
token->setName(casedName.localName());
}
-template<const QualifiedName* const* getAttrs(), unsigned length>
+template<void getAttrs(Vector<const QualifiedName*>&)>
static void adjustAttributes(AtomicHTMLToken* token)
{
static PrefixedNameToQualifiedNameMap* caseMap = 0;
if (!caseMap) {
caseMap = new PrefixedNameToQualifiedNameMap;
- const QualifiedName* const* attrs = getAttrs();
- mapLoweredLocalNameToName(caseMap, attrs, length);
+ Vector<const QualifiedName*> attrs;
+ getAttrs(attrs);
+ mapLoweredLocalNameToName(caseMap, attrs);
}
for (unsigned i = 0; i < token->attributes().size(); ++i) {
@@ -595,16 +598,17 @@ static void adjustAttributes(AtomicHTMLToken* token)
static void adjustSVGAttributes(AtomicHTMLToken* token)
{
- adjustAttributes<SVGNames::getSVGAttrs, SVGNames::SVGAttrsCount>(token);
+ adjustAttributes<SVGNames::getSVGAttrs>(token);
}
static void adjustMathMLAttributes(AtomicHTMLToken* token)
{
- adjustAttributes<MathMLNames::getMathMLAttrs, MathMLNames::MathMLAttrsCount>(token);
+ adjustAttributes<MathMLNames::getMathMLAttrs>(token);
}
-static void addNamesWithPrefix(PrefixedNameToQualifiedNameMap* map, const AtomicString& prefix, const QualifiedName* const* names, size_t length)
+static void addNamesWithPrefix(PrefixedNameToQualifiedNameMap* map, const AtomicString& prefix, const Vector<const QualifiedName*>& names)
{
+ size_t length = names.size();
for (size_t i = 0; i < length; ++i) {
const QualifiedName* name = names[i];
const AtomicString& localName = name->localName();
@@ -620,11 +624,12 @@ static void adjustForeignAttributes(AtomicHTMLToken* token)
if (!map) {
map = new PrefixedNameToQualifiedNameMap;
- const QualifiedName* const* attrs = XLinkNames::getXLinkAttrs();
- addNamesWithPrefix(map, xlinkAtom, attrs, XLinkNames::XLinkAttrsCount);
+ Vector<const QualifiedName*> attrs;
+ XLinkNames::getXLinkAttrs(attrs);
+ addNamesWithPrefix(map, xlinkAtom, attrs);
- attrs = XMLNames::getXMLAttrs();
- addNamesWithPrefix(map, xmlAtom, attrs, XMLNames::XMLAttrsCount);
+ XMLNames::getXMLAttrs(attrs);
+ addNamesWithPrefix(map, xmlAtom, attrs);
map->add(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr);
map->add("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom, XMLNSNames::xmlnsNamespaceURI));

Powered by Google App Engine
This is Rietveld 408576698