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

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
« no previous file with comments | « Source/core/html/parser/HTMLIdentifier.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLTreeBuilder.cpp
diff --git a/Source/core/html/parser/HTMLTreeBuilder.cpp b/Source/core/html/parser/HTMLTreeBuilder.cpp
index 0553f7384f9054e234ed2df991d0f728c1e81317..023cc44e277fbe20d31e9424139a401aa625f035 100644
--- a/Source/core/html/parser/HTMLTreeBuilder.cpp
+++ b/Source/core/html/parser/HTMLTreeBuilder.cpp
@@ -553,8 +553,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();
@@ -569,8 +570,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());
@@ -579,14 +581,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) {
@@ -599,16 +602,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();
@@ -624,11 +628,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));
« no previous file with comments | « Source/core/html/parser/HTMLIdentifier.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698