Diff
Modified: trunk/Source/WTF/ChangeLog (146418 => 146419)
--- trunk/Source/WTF/ChangeLog 2013-03-21 00:20:55 UTC (rev 146418)
+++ trunk/Source/WTF/ChangeLog 2013-03-21 00:31:45 UTC (rev 146419)
@@ -1,3 +1,17 @@
+2013-03-20 Adam Barth <[email protected]>
+
+ HTMLNames should construct strings at compile time
+ https://bugs.webkit.org/show_bug.cgi?id=112831
+
+ Reviewed by Darin Adler.
+
+ * wtf/text/StringImpl.h:
+ (StringImpl):
+ (StaticASCIILiteral):
+ - This struct lets us construct StringImpl objects at compile time.
+ (WTF::StringImpl::assertValidHash):
+ - This function lets us sanity check StringImpl objects created from StaticData.
+
2013-03-20 Jessie Berlin <[email protected]>
REGRESSION(r145592): AutodrainedPool.h. RunLoopTimer.h, SchedulePair.h are being copied into
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (146418 => 146419)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2013-03-21 00:20:55 UTC (rev 146418)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2013-03-21 00:31:45 UTC (rev 146419)
@@ -772,6 +772,32 @@
#ifdef STRING_STATS
WTF_EXPORTDATA static StringStats m_stringStats;
#endif
+
+public:
+ struct StaticASCIILiteral {
+ // These member variables must match the layout of StringImpl.
+ unsigned m_refCount;
+ unsigned m_length;
+ const LChar* m_data8;
+ void* m_buffer;
+ unsigned m_hashAndFlags;
+
+ // These values mimic ConstructFromLiteral.
+ static const unsigned s_initialRefCount = s_refCountIncrement;
+ static const unsigned s_initialFlags = s_hashFlag8BitBuffer | BufferInternal | s_hashFlagHasTerminatingNullCharacter;
+ static const unsigned s_hashShift = s_flagCount;
+ };
+
+#ifndef NDEBUG
+ void assertHashIsCorrect()
+ {
+ ASSERT(hasHash());
+ ASSERT(existingHash() == StringHasher::computeHashAndMaskTop8Bits(characters8(), length()));
+ }
+#endif
+
+private:
+ // These member variables must match the layout of StaticASCIILiteral.
unsigned m_refCount;
unsigned m_length;
union {
@@ -789,6 +815,8 @@
mutable unsigned m_hashAndFlags;
};
+COMPILE_ASSERT(sizeof(StringImpl) == sizeof(StringImpl::StaticASCIILiteral), StringImpl_should_match_its_StaticASCIILiteral);
+
template <>
ALWAYS_INLINE const LChar* StringImpl::getCharacters<LChar>() const { return characters8(); }
Modified: trunk/Source/WebCore/ChangeLog (146418 => 146419)
--- trunk/Source/WebCore/ChangeLog 2013-03-21 00:20:55 UTC (rev 146418)
+++ trunk/Source/WebCore/ChangeLog 2013-03-21 00:31:45 UTC (rev 146419)
@@ -1,3 +1,32 @@
+2013-03-20 Adam Barth <[email protected]>
+
+ HTMLNames should construct strings at compile time
+ https://bugs.webkit.org/show_bug.cgi?id=112831
+
+ Reviewed by Darin Adler.
+
+ This patch teaches make_names how to construct strings at compile time,
+ eliminating a large number of startup mallocs.
+
+ * WebCore.gyp/WebCore.gyp:
+ * WebCore.gyp/scripts/action_makenames.py:
+ - Teach the Chromium build how to deal with Perl modules.
+ * bindings/scripts/StaticString.pm: Added.
+ - A Perl module for constructing static strings.
+ (GenerateStrings):
+ (GenerateValidateStrings):
+ * dom/QualifiedName.cpp:
+ (WebCore::createQualifiedName):
+ - createQualifiedName now takes an already-constructed StringImpl
+ object.
+ * dom/QualifiedName.h:
+ * dom/make_names.pl:
+ (valueForName):
+ (namesToStrings):
+ (printNamesCppFile):
+ (printDefinitions):
+ - Teach make_names how to use StaticString.pm.
+
2013-03-20 Matt Falkenhagen <[email protected]>
Remove unnecessary calls to Node::disabled for <meter>, <progress>, and <output>
Modified: trunk/Source/WebCore/DerivedSources.make (146418 => 146419)
--- trunk/Source/WebCore/DerivedSources.make 2013-03-21 00:20:55 UTC (rev 146418)
+++ trunk/Source/WebCore/DerivedSources.make 2013-03-21 00:31:45 UTC (rev 146419)
@@ -826,7 +826,7 @@
# --------
-WebKitFontFamilyNames.cpp WebKitFontFamilyNames.h : dom/make_names.pl css/WebKitFontFamilyNames.in
+WebKitFontFamilyNames.cpp WebKitFontFamilyNames.h : dom/make_names.pl bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm css/WebKitFontFamilyNames.in
perl -I $(WebCore)/bindings/scripts $< --fonts $(WebCore)/css/WebKitFontFamilyNames.in
# HTML tag and attribute names
@@ -873,22 +873,22 @@
ifdef HTML_FLAGS
-HTMLElementFactory.cpp HTMLNames.cpp : dom/make_names.pl html/HTMLTagNames.in html/HTMLAttributeNames.in
+HTMLElementFactory.cpp HTMLNames.cpp : dom/make_names.pl bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm html/HTMLTagNames.in html/HTMLAttributeNames.in
perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/html/HTMLTagNames.in --attrs $(WebCore)/html/HTMLAttributeNames.in --factory --wrapperFactory --extraDefines "$(HTML_FLAGS)"
else
-HTMLElementFactory.cpp HTMLNames.cpp : dom/make_names.pl html/HTMLTagNames.in html/HTMLAttributeNames.in
+HTMLElementFactory.cpp HTMLNames.cpp : dom/make_names.pl bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm html/HTMLTagNames.in html/HTMLAttributeNames.in
perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/html/HTMLTagNames.in --attrs $(WebCore)/html/HTMLAttributeNames.in --factory --wrapperFactory
endif
JSHTMLElementWrapperFactory.cpp : HTMLNames.cpp
-XMLNSNames.cpp : dom/make_names.pl xml/xmlnsattrs.in
+XMLNSNames.cpp : dom/make_names.pl bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm xml/xmlnsattrs.in
perl -I $(WebCore)/bindings/scripts $< --attrs $(WebCore)/xml/xmlnsattrs.in
-XMLNames.cpp : dom/make_names.pl xml/xmlattrs.in
+XMLNames.cpp : dom/make_names.pl bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm xml/xmlattrs.in
perl -I $(WebCore)/bindings/scripts $< --attrs $(WebCore)/xml/xmlattrs.in
# --------
@@ -907,18 +907,18 @@
ifdef SVG_FLAGS
-SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl svg/svgtags.in svg/svgattrs.in
+SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm svg/svgtags.in svg/svgattrs.in
perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --extraDefines "$(SVG_FLAGS)" --factory --wrapperFactory
else
-SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl svg/svgtags.in svg/svgattrs.in
+SVGElementFactory.cpp SVGNames.cpp : dom/make_names.pl bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm svg/svgtags.in svg/svgattrs.in
perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --factory --wrapperFactory
endif
JSSVGElementWrapperFactory.cpp : SVGNames.cpp
-XLinkNames.cpp : dom/make_names.pl svg/xlinkattrs.in
+XLinkNames.cpp : dom/make_names.pl bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm svg/xlinkattrs.in
perl -I $(WebCore)/bindings/scripts $< --attrs $(WebCore)/svg/xlinkattrs.in
# --------
@@ -938,7 +938,7 @@
# MathML tag and attribute names, and element factory
-MathMLElementFactory.cpp MathMLNames.cpp : dom/make_names.pl mathml/mathtags.in mathml/mathattrs.in
+MathMLElementFactory.cpp MathMLNames.cpp : dom/make_names.pl bindings/scripts/Hasher.pm bindings/scripts/StaticString.pm mathml/mathtags.in mathml/mathattrs.in
perl -I $(WebCore)/bindings/scripts $< --tags $(WebCore)/mathml/mathtags.in --attrs $(WebCore)/mathml/mathattrs.in --factory --wrapperFactory
# --------
Modified: trunk/Source/WebCore/GNUmakefile.am (146418 => 146419)
--- trunk/Source/WebCore/GNUmakefile.am 2013-03-21 00:20:55 UTC (rev 146418)
+++ trunk/Source/WebCore/GNUmakefile.am 2013-03-21 00:31:45 UTC (rev 146419)
@@ -145,7 +145,7 @@
# MathML tag and attribute names, and element factory
DerivedSources/WebCore/MathMLElementFactory.h: DerivedSources/WebCore/MathMLElementFactory.cpp
DerivedSources/WebCore/MathMLNames.h: DerivedSources/WebCore/MathMLNames.cpp
-DerivedSources/WebCore/MathMLElementFactory.cpp DerivedSources/WebCore/MathMLNames.cpp: $(WebCore)/dom/make_names.pl $(WebCore)/mathml/mathtags.in $(WebCore)/mathml/mathattrs.in
+DerivedSources/WebCore/MathMLElementFactory.cpp DerivedSources/WebCore/MathMLNames.cpp: $(WebCore)/dom/make_names.pl $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/mathml/mathtags.in $(WebCore)/mathml/mathattrs.in
$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --tags $(WebCore)/mathml/mathtags.in --attrs $(WebCore)/mathml/mathattrs.in --factory --wrapperFactory --outputDir "$(GENSOURCES_WEBCORE)"
# ----
@@ -190,13 +190,13 @@
# SVG tag and attribute names (need to pass an extra flag if svg experimental features are enabled)
DerivedSources/WebCore/SVGNames.cpp: DerivedSources/WebCore/SVGElementFactory.cpp
DerivedSources/WebCore/JSSVGElementWrapperFactory.cpp: DerivedSources/WebCore/SVGElementFactory.cpp
-DerivedSources/WebCore/SVGElementFactory.cpp: $(WebCore)/dom/make_names.pl $(WebCore)/svg/svgtags.in $(WebCore)/svg/svgattrs.in
+DerivedSources/WebCore/SVGElementFactory.cpp: $(WebCore)/dom/make_names.pl $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/svg/svgtags.in $(WebCore)/svg/svgattrs.in
$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --tags $(WebCore)/svg/svgtags.in --attrs $(WebCore)/svg/svgattrs.in --extraDefines "$(feature_defines)" --factory --wrapperFactory --outputDir "$(GENSOURCES_WEBCORE)"
# end SVG Features
DerivedSources/WebCore/XLinkNames.h: DerivedSources/WebCore/XLinkNames.cpp
-DerivedSources/WebCore/XLinkNames.cpp : $(WebCore)/dom/make_names.pl $(WebCore)/svg/xlinkattrs.in
+DerivedSources/WebCore/XLinkNames.cpp : $(WebCore)/dom/make_names.pl $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/svg/xlinkattrs.in
$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --attrs $(WebCore)/svg/xlinkattrs.in --outputDir "$(GENSOURCES_WEBCORE)"
if USE_TEXTURE_MAPPER_CAIRO
@@ -293,7 +293,7 @@
$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --defines "$(feature_defines)" $@ DerivedSources/WebCore/UserAgentStyleSheetsData.cpp $(USER_AGENT_STYLE_SHEETS)
DerivedSources/WebCore/WebKitFontFamilyNames.cpp: DerivedSources/WebCore/WebKitFontFamilyNames.h
-DerivedSources/WebCore/WebKitFontFamilyNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/css/WebKitFontFamilyNames.in
+DerivedSources/WebCore/WebKitFontFamilyNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/css/WebKitFontFamilyNames.in
$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --fonts $(WebCore)/css/WebKitFontFamilyNames.in --outputDir "$(GENSOURCES_WEBCORE)"
@@ -302,14 +302,14 @@
DerivedSources/WebCore/HTMLElementFactory.cpp: DerivedSources/WebCore/HTMLElementFactory.h
DerivedSources/WebCore/HTMLElementFactory.h: DerivedSources/WebCore/HTMLNames.cpp
DerivedSources/WebCore/HTMLNames.cpp: DerivedSources/WebCore/HTMLNames.h
-DerivedSources/WebCore/HTMLNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/html/HTMLTagNames.in $(WebCore)/html/HTMLAttributeNames.in
+DerivedSources/WebCore/HTMLNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/html/HTMLTagNames.in $(WebCore)/html/HTMLAttributeNames.in
$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --tags $(WebCore)/html/HTMLTagNames.in --attrs $(WebCore)/html/HTMLAttributeNames.in --extraDefines "$(feature_defines)" --factory --wrapperFactory --outputDir "$(GENSOURCES_WEBCORE)"
-DerivedSources/WebCore/XMLNSNames.cpp DerivedSources/WebCore/XMLNSNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/xml/xmlnsattrs.in
+DerivedSources/WebCore/XMLNSNames.cpp DerivedSources/WebCore/XMLNSNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/xml/xmlnsattrs.in
$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --attrs $(WebCore)/xml/xmlnsattrs.in --outputDir "$(GENSOURCES_WEBCORE)"
-DerivedSources/WebCore/XMLNames.cpp DerivedSources/WebCore/XMLNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/xml/xmlattrs.in
+DerivedSources/WebCore/XMLNames.cpp DerivedSources/WebCore/XMLNames.h: $(WebCore)/dom/make_names.pl $(WebCore)/bindings/scripts/Hasher.pm $(WebCore)/bindings/scripts/StaticString.pm $(WebCore)/xml/xmlattrs.in
$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --attrs $(WebCore)/xml/xmlattrs.in --outputDir "$(GENSOURCES_WEBCORE)"
DerivedSources/WebCore/EventFactory.cpp DerivedSources/WebCore/EventHeaders.h DerivedSources/WebCore/EventInterfaces.h: $(WebCore)/dom/make_event_factory.pl $(WebCore)/dom/EventNames.in
Modified: trunk/Source/WebCore/WebCore.gyp/WebCore.gyp (146418 => 146419)
--- trunk/Source/WebCore/WebCore.gyp/WebCore.gyp 2013-03-21 00:20:55 UTC (rev 146418)
+++ trunk/Source/WebCore/WebCore.gyp/WebCore.gyp 2013-03-21 00:31:45 UTC (rev 146419)
@@ -746,6 +746,8 @@
{
'action_name': 'HTMLNames',
'inputs': [
+ '../bindings/scripts/Hasher.pm',
+ '../bindings/scripts/StaticString.pm',
'../dom/make_names.pl',
'../html/HTMLTagNames.in',
'../html/HTMLAttributeNames.in',
@@ -773,6 +775,8 @@
{
'action_name': 'WebKitFontFamilyNames',
'inputs': [
+ '../bindings/scripts/Hasher.pm',
+ '../bindings/scripts/StaticString.pm',
'../dom/make_names.pl',
'../css/WebKitFontFamilyNames.in',
],
@@ -794,6 +798,8 @@
{
'action_name': 'SVGNames',
'inputs': [
+ '../bindings/scripts/Hasher.pm',
+ '../bindings/scripts/StaticString.pm',
'../dom/make_names.pl',
'../svg/svgtags.in',
'../svg/svgattrs.in',
@@ -882,6 +888,8 @@
{
'action_name': 'MathMLNames',
'inputs': [
+ '../bindings/scripts/Hasher.pm',
+ '../bindings/scripts/StaticString.pm',
'../dom/make_names.pl',
'../mathml/mathtags.in',
'../mathml/mathattrs.in',
@@ -1016,6 +1024,8 @@
{
'action_name': 'XLinkNames',
'inputs': [
+ '../bindings/scripts/Hasher.pm',
+ '../bindings/scripts/StaticString.pm',
'../dom/make_names.pl',
'../svg/xlinkattrs.in',
],
@@ -1037,6 +1047,8 @@
{
'action_name': 'XMLNSNames',
'inputs': [
+ '../bindings/scripts/Hasher.pm',
+ '../bindings/scripts/StaticString.pm',
'../dom/make_names.pl',
'../xml/xmlnsattrs.in',
],
@@ -1058,6 +1070,8 @@
{
'action_name': 'XMLNames',
'inputs': [
+ '../bindings/scripts/Hasher.pm',
+ '../bindings/scripts/StaticString.pm',
'../dom/make_names.pl',
'../xml/xmlattrs.in',
],
Modified: trunk/Source/WebCore/WebCore.gyp/scripts/action_makenames.py (146418 => 146419)
--- trunk/Source/WebCore/WebCore.gyp/scripts/action_makenames.py 2013-03-21 00:20:55 UTC (rev 146418)
+++ trunk/Source/WebCore/WebCore.gyp/scripts/action_makenames.py 2013-03-21 00:31:45 UTC (rev 146419)
@@ -131,6 +131,8 @@
eventsInput = inputAbsPosix
elif inputBasename.endswith('Names.in'):
options.append(inputAbsPosix)
+ elif inputBasename.endswith('.pm'):
+ continue
else:
assert False
Added: trunk/Source/WebCore/bindings/scripts/StaticString.pm (0 => 146419)
--- trunk/Source/WebCore/bindings/scripts/StaticString.pm (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/StaticString.pm 2013-03-21 00:31:45 UTC (rev 146419)
@@ -0,0 +1,87 @@
+# Copyright (C) 2013 Google, Inc. All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package StaticString;
+
+use strict;
+use Hasher;
+
+sub GenerateStrings($)
+{
+ my $stringsRef = shift;
+ my %strings = %$stringsRef;
+
+ my @result = ();
+
+ while ( my ($name, $value) = each %strings ) {
+ push(@result, "static const LChar ${name}String8[] = \"${value}\";\n");
+ }
+
+ push(@result, "\n");
+
+ while ( my ($name, $value) = each %strings ) {
+ my $length = length($value);
+ my $hash = Hasher::GenerateHashValue($value);
+ push(@result, <<END);
+static StringImpl::StaticASCIILiteral ${name}Data = {
+ StringImpl::StaticASCIILiteral::s_initialRefCount,
+ $length,
+ ${name}String8,
+ 0,
+ StringImpl::StaticASCIILiteral::s_initialFlags | (${hash} << StringImpl::StaticASCIILiteral::s_hashShift)
+};
+END
+ }
+
+ push(@result, "\n");
+
+ while ( my ($name, $value) = each %strings ) {
+ push(@result, "static StringImpl* ${name}Impl = reinterpret_cast<StringImpl*>(&${name}Data);\n");
+ }
+
+ push(@result, "\n");
+
+ return join "", @result;
+}
+
+sub GenerateStringAsserts($)
+{
+ my $stringsRef = shift;
+ my %strings = %$stringsRef;
+
+ my @result = ();
+
+ push(@result, "#ifndef NDEBUG\n");
+
+ while ( my ($name, $value) = each %strings ) {
+ push(@result, " ${name}Impl->assertHashIsCorrect();\n");
+ }
+
+ push(@result, "#endif // NDEBUG\n");
+
+ push(@result, "\n");
+
+ return join "", @result;
+}
+
+1;
Modified: trunk/Source/WebCore/dom/QualifiedName.cpp (146418 => 146419)
--- trunk/Source/WebCore/dom/QualifiedName.cpp 2013-03-21 00:20:55 UTC (rev 146418)
+++ trunk/Source/WebCore/dom/QualifiedName.cpp 2013-03-21 00:31:45 UTC (rev 146419)
@@ -172,16 +172,14 @@
return hashComponents(components);
}
-void createQualifiedName(void* targetAddress, const char* name, unsigned nameLength, const AtomicString& nameNamespace)
+void createQualifiedName(void* targetAddress, StringImpl* name, const AtomicString& nameNamespace)
{
- AtomicString atomicName(name, nameLength, AtomicString::ConstructFromLiteral);
- new (reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom, atomicName, nameNamespace);
+ new (reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom, AtomicString(name), nameNamespace);
}
-void createQualifiedName(void* targetAddress, const char* name, unsigned nameLength)
+void createQualifiedName(void* targetAddress, StringImpl* name)
{
- AtomicString atomicName(name, nameLength, AtomicString::ConstructFromLiteral);
- new (reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom, atomicName, nullAtom);
+ new (reinterpret_cast<void*>(targetAddress)) QualifiedName(nullAtom, AtomicString(name), nullAtom);
}
}
Modified: trunk/Source/WebCore/dom/QualifiedName.h (146418 => 146419)
--- trunk/Source/WebCore/dom/QualifiedName.h 2013-03-21 00:20:55 UTC (rev 146418)
+++ trunk/Source/WebCore/dom/QualifiedName.h 2013-03-21 00:31:45 UTC (rev 146419)
@@ -144,8 +144,8 @@
static const bool safeToCompareToEmptyOrDeleted = false;
};
-void createQualifiedName(void* targetAddress, const char* name, unsigned nameLength);
-void createQualifiedName(void* targetAddress, const char* name, unsigned nameLength, const AtomicString& nameNamespace);
+void createQualifiedName(void* targetAddress, StringImpl* name);
+void createQualifiedName(void* targetAddress, StringImpl* name, const AtomicString& nameNamespace);
}
Modified: trunk/Source/WebCore/dom/make_names.pl (146418 => 146419)
--- trunk/Source/WebCore/dom/make_names.pl 2013-03-21 00:20:55 UTC (rev 146418)
+++ trunk/Source/WebCore/dom/make_names.pl 2013-03-21 00:31:45 UTC (rev 146419)
@@ -31,6 +31,7 @@
use strict;
+use StaticString;
use Config;
use Getopt::Long;
use File::Path;
@@ -54,6 +55,7 @@
my %enabledAttrs = ();
my %allTags = ();
my %allAttrs = ();
+my %allStrings = ();
my %parameters = ();
my $extraDefines = 0;
my $initDefaults = 1;
@@ -115,14 +117,19 @@
printLicenseHeader($F);
printCppHead($F, "CSS", $familyNamesFileBase, "WTF");
+ print F StaticString::GenerateStrings(\%parameters);
+
while ( my ($name, $identifier) = each %parameters ) {
print F "DEFINE_GLOBAL(AtomicString, $name)\n";
}
printInit($F, 0);
+ print F "\n";
+ print F StaticString::GenerateStringAsserts(\%parameters);
+
while ( my ($name, $identifier) = each %parameters ) {
- print F " new ((void*)&$name) AtomicString(\"$identifier\");\n";
+ print F " new ((void*)&$name) AtomicString(${name}Impl);\n";
}
print F "}\n}\n}\n";
@@ -135,11 +142,13 @@
if (length($tagsFile)) {
%allTags = %{readTags($tagsFile, 0)};
%enabledTags = %{readTags($tagsFile, 1)};
+ namesToStrings(\%allTags, \%allStrings);
}
if (length($attrsFile)) {
%allAttrs = %{readAttrs($attrsFile, 0)};
%enabledAttrs = %{readAttrs($attrsFile, 1)};
+ namesToStrings(\%allAttrs, \%allStrings);
}
die "You must specify a namespace (e.g. SVG) for <namespace>Names.h" unless $parameters{namespace};
@@ -212,6 +221,31 @@
### Parsing handlers
+sub valueForName
+{
+ my $name = shift;
+ my $value = $extensionAttrs{$name};
+
+ if (!$value) {
+ $value = $name;
+ $value =~ s/_/-/g;
+ }
+
+ return $value;
+}
+
+sub namesToStrings
+{
+ my $namesRef = shift;
+ my $stringsRef = shift;
+
+ my %names = %$namesRef;
+
+ for my $name (keys %names) {
+ $stringsRef->{$name} = valueForName($name);
+ }
+}
+
sub tagsHandler
{
my ($tag, $property, $value) = @_;
@@ -636,6 +670,8 @@
print F "DEFINE_GLOBAL(AtomicString, ${lowerNamespace}NamespaceURI)\n\n";
+ print F StaticString::GenerateStrings(\%allStrings);
+
if (keys %allTags) {
print F "// Tags\n";
for my $name (sort keys %allTags) {
@@ -672,7 +708,10 @@
print(F " AtomicString ${lowerNamespace}NS(\"$parameters{namespaceURI}\", AtomicString::ConstructFromLiteral);\n\n");
print(F " // Namespace\n");
- print(F " new ((void*)&${lowerNamespace}NamespaceURI) AtomicString(${lowerNamespace}NS);\n\n");
+ print(F " new ((void*)&${lowerNamespace}NamespaceURI) AtomicString(${lowerNamespace}NS);\n");
+ print(F "\n");
+ print F StaticString::GenerateStringAsserts(\%allStrings);
+
if (keys %allTags) {
my $tagsNamespace = $parameters{tagsNullNamespace} ? "nullAtom" : "${lowerNamespace}NS";
printDefinitions($F, \%allTags, "tags", $tagsNamespace);
@@ -774,17 +813,11 @@
print F " // " . ucfirst($type) . "\n";
for my $name (sort keys %$namesRef) {
- my $realName = $extensionAttrs{$name};
- if (!$realName) {
- $realName = $name;
- $realName =~ s/_/-/g;
- }
-
# To generate less code in init(), the common case of nullAtom for the namespace, we call createQualifiedName() without passing $namespaceURI.
if ($namespaceURI eq "nullAtom") {
- print F " createQualifiedName((void*)&$name","${shortCamelType}, \"$realName\", ", length $realName ,");\n";
+ print F " createQualifiedName((void*)&$name","${shortCamelType}, ${name}Impl);\n";
} else {
- print F " createQualifiedName((void*)&$name","${shortCamelType}, \"$realName\", ", length $realName ,", $namespaceURI);\n";
+ print F " createQualifiedName((void*)&$name","${shortCamelType}, ${name}Impl, $namespaceURI);\n";
}
}
}