- Revision
- 123804
- Author
- benja...@webkit.org
- Date
- 2012-07-26 15:41:04 -0700 (Thu, 26 Jul 2012)
Log Message
Use the constant count of Tags/Attributes names instead of getting the size when obtaining the tags/attributes
https://bugs.webkit.org/show_bug.cgi?id=92411
Patch by Benjamin Poulain <bpoul...@apple.com> on 2012-07-26
Reviewed by Julien Chaffraix.
Since r123582, the number of tags and attributes per "namespace" is exposed in a constant in the header file.
This makes it possible to access this value through two ways:
1) The constant.
2) The first parameter of the tags/attributes getter function.
Having two ways to access the value is error prone. This patches changes the code to have all accesses done
through the constant.
* dom/make_names.pl:
(printNamesHeaderFile):
(printNamesCppFile):
Change the code generator to not provide the size in the getter function.
* html/HTMLObjectElement.cpp:
(WebCore::isRecognizedTagName):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::adjustSVGTagNameCase):
(WebCore):
(WebCore::adjustAttributes):
(WebCore::adjustSVGAttributes):
(WebCore::adjustMathMLAttributes):
(WebCore::adjustForeignAttributes):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (123803 => 123804)
--- trunk/Source/WebCore/ChangeLog 2012-07-26 22:40:35 UTC (rev 123803)
+++ trunk/Source/WebCore/ChangeLog 2012-07-26 22:41:04 UTC (rev 123804)
@@ -1,3 +1,33 @@
+2012-07-26 Benjamin Poulain <bpoul...@apple.com>
+
+ Use the constant count of Tags/Attributes names instead of getting the size when obtaining the tags/attributes
+ https://bugs.webkit.org/show_bug.cgi?id=92411
+
+ Reviewed by Julien Chaffraix.
+
+ Since r123582, the number of tags and attributes per "namespace" is exposed in a constant in the header file.
+ This makes it possible to access this value through two ways:
+ 1) The constant.
+ 2) The first parameter of the tags/attributes getter function.
+
+ Having two ways to access the value is error prone. This patches changes the code to have all accesses done
+ through the constant.
+
+ * dom/make_names.pl:
+ (printNamesHeaderFile):
+ (printNamesCppFile):
+ Change the code generator to not provide the size in the getter function.
+
+ * html/HTMLObjectElement.cpp:
+ (WebCore::isRecognizedTagName):
+ * html/parser/HTMLTreeBuilder.cpp:
+ (WebCore::adjustSVGTagNameCase):
+ (WebCore):
+ (WebCore::adjustAttributes):
+ (WebCore::adjustSVGAttributes):
+ (WebCore::adjustMathMLAttributes):
+ (WebCore::adjustForeignAttributes):
+
2012-07-26 Chang Shu <c...@webkit.org>
Support constructor-type static readonly attribute for CodeGenerator.
Modified: trunk/Source/WebCore/dom/make_names.pl (123803 => 123804)
--- trunk/Source/WebCore/dom/make_names.pl 2012-07-26 22:40:35 UTC (rev 123803)
+++ trunk/Source/WebCore/dom/make_names.pl 2012-07-26 22:41:04 UTC (rev 123804)
@@ -601,12 +601,12 @@
if (keys %allTags) {
print F "const unsigned $parameters{namespace}TagsCount = ", scalar(keys %allTags), ";\n";
- print F "WebCore::QualifiedName** get$parameters{namespace}Tags(size_t* size);\n";
+ print F "WebCore::QualifiedName** get$parameters{namespace}Tags();\n";
}
if (keys %allAttrs) {
print F "const unsigned $parameters{namespace}AttrsCount = ", scalar(keys %allAttrs), ";\n";
- print F "WebCore::QualifiedName** get$parameters{namespace}Attrs(size_t* size);\n";
+ print F "WebCore::QualifiedName** get$parameters{namespace}Attrs();\n";
}
printInit($F, 1);
@@ -632,13 +632,12 @@
print F "DEFINE_GLOBAL(QualifiedName, ", $name, "Tag)\n";
}
- print F "\n\nWebCore::QualifiedName** get$parameters{namespace}Tags(size_t* size)\n";
+ print F "\n\nWebCore::QualifiedName** get$parameters{namespace}Tags()\n";
print F "{\n static WebCore::QualifiedName* $parameters{namespace}Tags[] = {\n";
for my $name (sort keys %allTags) {
print F " (WebCore::QualifiedName*)&${name}Tag,\n";
}
print F " };\n";
- print F " *size = ", scalar(keys %allTags), ";\n";
print F " return $parameters{namespace}Tags;\n";
print F "}\n";
}
@@ -648,13 +647,12 @@
for my $name (sort keys %allAttrs) {
print F "DEFINE_GLOBAL(QualifiedName, ", $name, "Attr)\n";
}
- print F "\n\nWebCore::QualifiedName** get$parameters{namespace}Attrs(size_t* size)\n";
+ print F "\n\nWebCore::QualifiedName** get$parameters{namespace}Attrs()\n";
print F "{\n static WebCore::QualifiedName* $parameters{namespace}Attr[] = {\n";
for my $name (sort keys %allAttrs) {
print F " (WebCore::QualifiedName*)&${name}Attr,\n";
}
print F " };\n";
- print F " *size = ", scalar(keys %allAttrs), ";\n";
print F " return $parameters{namespace}Attr;\n";
print F "}\n";
}
Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (123803 => 123804)
--- trunk/Source/WebCore/html/HTMLObjectElement.cpp 2012-07-26 22:40:35 UTC (rev 123803)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp 2012-07-26 22:41:04 UTC (rev 123804)
@@ -398,9 +398,8 @@
{
DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ());
if (tagList.isEmpty()) {
- size_t tagCount = 0;
- QualifiedName** tags = HTMLNames::getHTMLTags(&tagCount);
- for (size_t i = 0; i < tagCount; i++) {
+ QualifiedName** tags = HTMLNames::getHTMLTags();
+ for (size_t i = 0; i < HTMLNames::HTMLTagsCount; i++) {
if (*tags[i] == bgsoundTag
|| *tags[i] == commandTag
|| *tags[i] == detailsTag
Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (123803 => 123804)
--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp 2012-07-26 22:40:35 UTC (rev 123803)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp 2012-07-26 22:41:04 UTC (rev 123804)
@@ -656,9 +656,8 @@
static PrefixedNameToQualifiedNameMap* caseMap = 0;
if (!caseMap) {
caseMap = new PrefixedNameToQualifiedNameMap;
- size_t length = 0;
- QualifiedName** svgTags = SVGNames::getSVGTags(&length);
- mapLoweredLocalNameToName(caseMap, svgTags, length);
+ QualifiedName** svgTags = SVGNames::getSVGTags();
+ mapLoweredLocalNameToName(caseMap, svgTags, SVGNames::SVGTagsCount);
}
const QualifiedName& casedName = caseMap->get(token->name());
@@ -667,14 +666,13 @@
token->setName(casedName.localName());
}
-template<QualifiedName** getAttrs(size_t* length)>
+template<QualifiedName** getAttrs(), unsigned length>
static void adjustAttributes(AtomicHTMLToken* token)
{
static PrefixedNameToQualifiedNameMap* caseMap = 0;
if (!caseMap) {
caseMap = new PrefixedNameToQualifiedNameMap;
- size_t length = 0;
- QualifiedName** attrs = getAttrs(&length);
+ QualifiedName** attrs = getAttrs();
mapLoweredLocalNameToName(caseMap, attrs, length);
}
@@ -688,12 +686,12 @@
static void adjustSVGAttributes(AtomicHTMLToken* token)
{
- adjustAttributes<SVGNames::getSVGAttrs>(token);
+ adjustAttributes<SVGNames::getSVGAttrs, SVGNames::SVGAttrsCount>(token);
}
static void adjustMathMLAttributes(AtomicHTMLToken* token)
{
- adjustAttributes<MathMLNames::getMathMLAttrs>(token);
+ adjustAttributes<MathMLNames::getMathMLAttrs, MathMLNames::MathMLAttrsCount>(token);
}
static void addNamesWithPrefix(PrefixedNameToQualifiedNameMap* map, const AtomicString& prefix, QualifiedName** names, size_t length)
@@ -712,12 +710,11 @@
static PrefixedNameToQualifiedNameMap* map = 0;
if (!map) {
map = new PrefixedNameToQualifiedNameMap;
- size_t length = 0;
- QualifiedName** attrs = XLinkNames::getXLinkAttrs(&length);
- addNamesWithPrefix(map, "xlink", attrs, length);
+ QualifiedName** attrs = XLinkNames::getXLinkAttrs();
+ addNamesWithPrefix(map, "xlink", attrs, XLinkNames::XLinkAttrsCount);
- attrs = XMLNames::getXMLAttrs(&length);
- addNamesWithPrefix(map, "xml", attrs, length);
+ attrs = XMLNames::getXMLAttrs();
+ addNamesWithPrefix(map, "xml", attrs, XMLNames::XMLAttrsCount);
map->add("xmlns", XMLNSNames::xmlnsAttr);
map->add("xmlns:xlink", QualifiedName("xmlns", "xlink", XMLNSNames::xmlnsNamespaceURI));