Deploy ASCIILiteral and StringBuilder in more places in WebCore
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 07:32:31 +0000 (07:32 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 07:32:31 +0000 (07:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=95291

Reviewed by Benjamin Poulain.

I wanted to deploy ASCIILiteral in more places in WebCore, but there's
a bunch of code that should be using StringBuilder, which I couldn't
resist deploying as well.

* Modules/mediastream/PeerConnection00.cpp:
(WebCore::PeerConnection00::createIceOptions):
* bindings/js/JSBlobCustom.cpp:
(WebCore::JSBlobConstructor::constructJSBlob):
* bindings/v8/V8LazyEventListener.cpp:
(WebCore::V8LazyEventListener::prepareListenerObject):
* bindings/v8/custom/V8BlobCustom.cpp:
(WebCore::V8Blob::constructorCallback):
* css/CSSCanvasValue.cpp:
(WebCore::CSSCanvasValue::customCssText):
* css/CSSCrossfadeValue.cpp:
(WebCore::CSSCrossfadeValue::customCssText):
* css/CSSPageRule.cpp:
(WebCore::CSSPageRule::selectorText):
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText):
* editing/EditorCommand.cpp:
(WebCore::executeToggleStyleInList):
* editing/SmartReplaceICU.cpp:
(WebCore::getSmartSet):
* editing/markup.cpp:
(WebCore::fillContainerFromString):
* html/HTMLTitleElement.cpp:
(WebCore::HTMLTitleElement::text):
* inspector/InspectorConsoleAgent.cpp:
(WebCore::InspectorConsoleAgent::didFailLoading):
* page/EventSource.cpp:
(WebCore::EventSource::didReceiveResponse):
* platform/blackberry/LocalizedStringsBlackBerry.cpp:
(WebCore::platformLanguage):
* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::animationNameForTransition):
* platform/network/blackberry/rss/RSSAtomParser.cpp:
(WebCore::RSSAtomParser::parseContent):
* platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::open):
(WebCore::SQLiteDatabase::setFullsync):
(WebCore::SQLiteDatabase::maximumSize):
(WebCore::SQLiteDatabase::pageSize):
(WebCore::SQLiteDatabase::freeSpaceSize):
(WebCore::SQLiteDatabase::totalSize):
(WebCore::SQLiteDatabase::tableExists):
(WebCore::SQLiteDatabase::clearAllTables):
(WebCore::SQLiteDatabase::runVacuumCommand):
(WebCore::SQLiteDatabase::runIncrementalVacuumCommand):
(WebCore::SQLiteDatabase::turnOnIncrementalAutoVacuum):
* platform/win/FileSystemWin.cpp:
(WebCore::bundleName):
(WebCore::storageDirectory):
* plugins/PluginStream.cpp:
(WebCore::PluginStream::startStream):
* rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::setTextFromOption):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126967 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/PeerConnection00.cpp
Source/WebCore/bindings/js/JSBlobCustom.cpp
Source/WebCore/bindings/v8/V8LazyEventListener.cpp
Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp
Source/WebCore/css/CSSCanvasValue.cpp
Source/WebCore/css/CSSCrossfadeValue.cpp
Source/WebCore/css/CSSPageRule.cpp
Source/WebCore/css/CSSSelector.cpp
Source/WebCore/editing/EditorCommand.cpp
Source/WebCore/editing/SmartReplaceICU.cpp
Source/WebCore/editing/markup.cpp
Source/WebCore/html/HTMLTitleElement.cpp
Source/WebCore/inspector/InspectorConsoleAgent.cpp
Source/WebCore/page/EventSource.cpp
Source/WebCore/platform/blackberry/LocalizedStringsBlackBerry.cpp
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/network/blackberry/rss/RSSAtomParser.cpp
Source/WebCore/platform/sql/SQLiteDatabase.cpp
Source/WebCore/platform/win/FileSystemWin.cpp
Source/WebCore/plugins/PluginStream.cpp
Source/WebCore/rendering/RenderMenuList.cpp

index 8e0ed56aec8cc79dadb8357be4c885ec5c4c60f1..d21e1ff35424d06890db5d86fb803e98083d1789 100644 (file)
@@ -1,3 +1,68 @@
+2012-08-28  Adam Barth  <abarth@webkit.org>
+
+        Deploy ASCIILiteral and StringBuilder in more places in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=95291
+
+        Reviewed by Benjamin Poulain.
+
+        I wanted to deploy ASCIILiteral in more places in WebCore, but there's
+        a bunch of code that should be using StringBuilder, which I couldn't
+        resist deploying as well.
+
+        * Modules/mediastream/PeerConnection00.cpp:
+        (WebCore::PeerConnection00::createIceOptions):
+        * bindings/js/JSBlobCustom.cpp:
+        (WebCore::JSBlobConstructor::constructJSBlob):
+        * bindings/v8/V8LazyEventListener.cpp:
+        (WebCore::V8LazyEventListener::prepareListenerObject):
+        * bindings/v8/custom/V8BlobCustom.cpp:
+        (WebCore::V8Blob::constructorCallback):
+        * css/CSSCanvasValue.cpp:
+        (WebCore::CSSCanvasValue::customCssText):
+        * css/CSSCrossfadeValue.cpp:
+        (WebCore::CSSCrossfadeValue::customCssText):
+        * css/CSSPageRule.cpp:
+        (WebCore::CSSPageRule::selectorText):
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::selectorText):
+        * editing/EditorCommand.cpp:
+        (WebCore::executeToggleStyleInList):
+        * editing/SmartReplaceICU.cpp:
+        (WebCore::getSmartSet):
+        * editing/markup.cpp:
+        (WebCore::fillContainerFromString):
+        * html/HTMLTitleElement.cpp:
+        (WebCore::HTMLTitleElement::text):
+        * inspector/InspectorConsoleAgent.cpp:
+        (WebCore::InspectorConsoleAgent::didFailLoading):
+        * page/EventSource.cpp:
+        (WebCore::EventSource::didReceiveResponse):
+        * platform/blackberry/LocalizedStringsBlackBerry.cpp:
+        (WebCore::platformLanguage):
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::animationNameForTransition):
+        * platform/network/blackberry/rss/RSSAtomParser.cpp:
+        (WebCore::RSSAtomParser::parseContent):
+        * platform/sql/SQLiteDatabase.cpp:
+        (WebCore::SQLiteDatabase::open):
+        (WebCore::SQLiteDatabase::setFullsync):
+        (WebCore::SQLiteDatabase::maximumSize):
+        (WebCore::SQLiteDatabase::pageSize):
+        (WebCore::SQLiteDatabase::freeSpaceSize):
+        (WebCore::SQLiteDatabase::totalSize):
+        (WebCore::SQLiteDatabase::tableExists):
+        (WebCore::SQLiteDatabase::clearAllTables):
+        (WebCore::SQLiteDatabase::runVacuumCommand):
+        (WebCore::SQLiteDatabase::runIncrementalVacuumCommand):
+        (WebCore::SQLiteDatabase::turnOnIncrementalAutoVacuum):
+        * platform/win/FileSystemWin.cpp:
+        (WebCore::bundleName):
+        (WebCore::storageDirectory):
+        * plugins/PluginStream.cpp:
+        (WebCore::PluginStream::startStream):
+        * rendering/RenderMenuList.cpp:
+        (WebCore::RenderMenuList::setTextFromOption):
+
 2012-08-29  Yoshifumi Inoue  <yosin@chromium.org>
 
         [Forms] Make HTMLInputElement::blur()/focus() override-able by input type
index 9a61fc342a47377ef47054b62ffdc88d91fa01ac..8556d08c1fb9e902e87ca435558fd652eccd6389 100644 (file)
@@ -229,7 +229,7 @@ PassRefPtr<SessionDescription> PeerConnection00::remoteDescription()
 
 PassRefPtr<IceOptions> PeerConnection00::createIceOptions(const Dictionary& dictionary, ExceptionCode& ec)
 {
-    String useCandidates = "";
+    String useCandidates = emptyString();
     dictionary.get("use_candidates", useCandidates);
 
     IceOptions::UseCandidatesOption option;
index 6a9122c2e3335d66d366b3565b368501c9878d3c..49ca2964c564ff861cacb8f73ab3f6603e49fda4 100644 (file)
@@ -76,7 +76,7 @@ EncodedJSValue JSC_HOST_CALL JSBlobConstructor::constructJSBlob(ExecState* exec)
         return throwVMError(exec, createTypeError(exec, "First argument of the constructor is not of type Array"));
 
     String type;
-    String endings = "transparent";
+    String endings = ASCIILiteral("transparent");
 
     if (exec->argumentCount() > 1) {
         JSValue blobPropertyBagValue = exec->argument(1);
index d548b16076e6ad2cb618c9649596b81fa024ea42..c1bbdbf7756e8b0757a8ad04b9244411a1a8ae3d 100644 (file)
@@ -145,10 +145,10 @@ void V8LazyEventListener::prepareListenerObject(ScriptExecutionContext* context)
     // Call with 4 arguments instead of 3, pass additional null as the last parameter.
     // By calling the function with 4 arguments, we create a setter on arguments object
     // which would shadow property "3" on the prototype.
-    String code = "(function() {" \
+    String code = ASCIILiteral("(function() {" \
         "with (this[2]) {" \
         "with (this[1]) {" \
-        "with (this[0]) {";
+        "with (this[0]) {");
     code.append("return function(");
     code.append(m_eventParameterName);
     code.append(") {");
@@ -219,7 +219,7 @@ void V8LazyEventListener::prepareListenerObject(ScriptExecutionContext* context)
     if (!toStringTemplate.IsEmpty())
         toStringFunction = toStringTemplate->GetFunction();
     if (!toStringFunction.IsEmpty()) {
-        String toStringResult = "function ";
+        String toStringResult = ASCIILiteral("function ");
         toStringResult.append(m_functionName);
         toStringResult.append("(");
         toStringResult.append(m_eventParameterName);
index 1112e540605e7c977822b211c168ba05e8f47879..c24f4d349df5f5a97cc9039f2d384502c868611d 100644 (file)
@@ -79,7 +79,7 @@ v8::Handle<v8::Value> V8Blob::constructorCallback(const v8::Arguments& args)
         return throwTypeError("First argument of the constructor is not of type Array", args.GetIsolate());
 
     String type;
-    String endings = "transparent";
+    String endings = ASCIILiteral("transparent");
 
     if (args.Length() > 1) {
         if (!args[1]->IsObject())
index 63777bb4dddda097616f8fa0abc1ba5c77fb9455..c4c465cd5215e95fafd1c14dcf46a2c6eadb648a 100644 (file)
@@ -29,6 +29,7 @@
 #include "ImageBuffer.h"
 #include "MemoryInstrumentation.h"
 #include "RenderObject.h"
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
@@ -40,9 +41,11 @@ CSSCanvasValue::~CSSCanvasValue()
 
 String CSSCanvasValue::customCssText() const
 {
-    String result = "-webkit-canvas(";
-    result += m_name  + ")";
-    return result;
+    StringBuilder result;
+    result.appendLiteral("-webkit-canvas(");
+    result.append(m_name);
+    result.append(')');
+    return result.toString();
 }
 
 void CSSCanvasValue::canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect)
index 5ed7da18d3cb9e9ad80c2be7818262ec382b4e29..6ccc8b7dbad2e82ffb5820317f44e3fbe676d18c 100644 (file)
@@ -35,6 +35,7 @@
 #include "RenderObject.h"
 #include "StyleCachedImage.h"
 #include "StyleGeneratedImage.h"
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
@@ -85,12 +86,15 @@ CSSCrossfadeValue::~CSSCrossfadeValue()
 
 String CSSCrossfadeValue::customCssText() const
 {
-    String result = "-webkit-cross-fade(";
-    result += m_fromValue->cssText() + ", ";
-    result += m_toValue->cssText() + ", ";
-    result += m_percentageValue->cssText();
-    result += ")";
-    return result;
+    StringBuilder result;
+    result.appendLiteral("-webkit-cross-fade(");
+    result.append(m_fromValue->cssText());
+    result.appendLiteral(", ");
+    result.append(m_toValue->cssText());
+    result.appendLiteral(", ");
+    result.append(m_percentageValue->cssText());
+    result.append(')');
+    return result.toString();
 }
 
 IntSize CSSCrossfadeValue::fixedSize(const RenderObject* renderer)
index 0a05f5e3f421aa76951e974e91ff4b8ed7e8482a..6f0da805a35640b0a8ecf1fd24c66e8d8865ff25 100644 (file)
@@ -55,14 +55,17 @@ CSSStyleDeclaration* CSSPageRule::style() const
 
 String CSSPageRule::selectorText() const
 {
-    String text = "@page";
+    StringBuilder text;
+    text.appendLiteral("@page");
     const CSSSelector* selector = m_pageRule->selector();
     if (selector) {
         String pageSpecification = selector->selectorText();
-        if (!pageSpecification.isEmpty() && pageSpecification != starAtom)
-            text += " " + pageSpecification;
+        if (!pageSpecification.isEmpty() && pageSpecification != starAtom) {
+            text.append(' ');
+            text.append(pageSpecification);
+        }
     }
-    return text;
+    return text.toString();
 }
 
 void CSSPageRule::setSelectorText(const String& selectorText)
index eabee493a41ab7e4427cf28fd703481b0ad0879a..5c26256a8a68c06537083311e684f1610b4aa3b7 100644 (file)
@@ -33,6 +33,7 @@
 #include <wtf/HashMap.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/Vector.h>
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
@@ -515,16 +516,16 @@ bool CSSSelector::operator==(const CSSSelector& other)
 
 String CSSSelector::selectorText() const
 {
-    String str = "";
+    StringBuilder str;
 
     const AtomicString& prefix = m_tag.prefix();
     const AtomicString& localName = m_tag.localName();
     if (m_match == CSSSelector::None || !prefix.isNull() || localName != starAtom) {
         if (prefix.isNull())
-            str = localName;
+            str.append(localName);
         else {
-            str = prefix.string();
-            str.append("|");
+            str.append(prefix.string());
+            str.append('|');
             str.append(localName);
         }
     }
@@ -532,82 +533,82 @@ String CSSSelector::selectorText() const
     const CSSSelector* cs = this;
     while (true) {
         if (cs->m_match == CSSSelector::Id) {
-            str += "#";
+            str.append('#');
             serializeIdentifier(cs->value(), str);
         } else if (cs->m_match == CSSSelector::Class) {
-            str += ".";
+            str.append('.');
             serializeIdentifier(cs->value(), str);
         } else if (cs->m_match == CSSSelector::PseudoClass || cs->m_match == CSSSelector::PagePseudoClass) {
-            str += ":";
-            str += cs->value();
+            str.append(':');
+            str.append(cs->value());
 
             switch (cs->pseudoType()) {
             case PseudoNot:
                 if (CSSSelectorList* selectorList = cs->selectorList())
-                    str += selectorList->first()->selectorText();
-                str += ")";
+                    str.append(selectorList->first()->selectorText());
+                str.append(')');
                 break;
             case PseudoLang:
             case PseudoNthChild:
             case PseudoNthLastChild:
             case PseudoNthOfType:
             case PseudoNthLastOfType:
-                str += cs->argument();
-                str += ")";
+                str.append(cs->argument());
+                str.append(')');
                 break;
             case PseudoAny: {
                 CSSSelector* firstSubSelector = cs->selectorList()->first();
                 for (CSSSelector* subSelector = firstSubSelector; subSelector; subSelector = CSSSelectorList::next(subSelector)) {
                     if (subSelector != firstSubSelector)
-                        str += ",";
-                    str += subSelector->selectorText();
+                        str.append(',');
+                    str.append(subSelector->selectorText());
                 }
-                str += ")";
+                str.append(')');
                 break;
             }
             default:
                 break;
             }
         } else if (cs->m_match == CSSSelector::PseudoElement) {
-            str += "::";
-            str += cs->value();
+            str.appendLiteral("::");
+            str.append(cs->value());
         } else if (cs->isAttributeSelector()) {
-            str += "[";
+            str.append('[');
             const AtomicString& prefix = cs->attribute().prefix();
             if (!prefix.isNull()) {
                 str.append(prefix);
                 str.append("|");
             }
-            str += cs->attribute().localName();
+            str.append(cs->attribute().localName());
             switch (cs->m_match) {
                 case CSSSelector::Exact:
-                    str += "=";
+                    str.append('=');
                     break;
                 case CSSSelector::Set:
                     // set has no operator or value, just the attrName
-                    str += "]";
+                    str.append(']');
                     break;
                 case CSSSelector::List:
-                    str += "~=";
+                    str.appendLiteral("~=");
                     break;
                 case CSSSelector::Hyphen:
-                    str += "|=";
+                    str.appendLiteral("|=");
                     break;
                 case CSSSelector::Begin:
-                    str += "^=";
+                    str.appendLiteral("^=");
                     break;
                 case CSSSelector::End:
-                    str += "$=";
+                    str.appendLiteral("$=");
                     break;
                 case CSSSelector::Contain:
-                    str += "*=";
+                    str.appendLiteral("*=");
                     break;
                 default:
                     break;
             }
             if (cs->m_match != CSSSelector::Set) {
                 serializeString(cs->value(), str);
-                str += "]";
+                str.append(']');
             }
         }
         if (cs->relation() != CSSSelector::SubSelector || !cs->tagHistory())
@@ -618,19 +619,20 @@ String CSSSelector::selectorText() const
     if (CSSSelector* tagHistory = cs->tagHistory()) {
         String tagHistoryText = tagHistory->selectorText();
         if (cs->relation() == CSSSelector::DirectAdjacent)
-            str = tagHistoryText + " + " + str;
+            return tagHistoryText + " + " + str.toString();
         else if (cs->relation() == CSSSelector::IndirectAdjacent)
-            str = tagHistoryText + " ~ " + str;
+            return tagHistoryText + " ~ " + str.toString();
         else if (cs->relation() == CSSSelector::Child)
-            str = tagHistoryText + " > " + str;
+            return tagHistoryText + " > " + str.toString();
         else if (cs->relation() == CSSSelector::ShadowDescendant)
-            str = tagHistoryText + str;
-        else
+            return tagHistoryText + str.toString();
+        else {
             // Descendant
-            str = tagHistoryText + " " + str;
+            return tagHistoryText + " " + str.toString();
+        }
     }
 
-    return str;
+    return str.toString();
 }
 
 void CSSSelector::setAttribute(const QualifiedName& value)
index 478ab6c5aa07b1974ba0aedce52dd4de44999713..42e15ebb2b4f88604cd576b2c813df5bb173cac5 100644 (file)
@@ -139,7 +139,7 @@ static bool executeToggleStyleInList(Frame* frame, EditorCommandSource source, E
         return false;
 
     RefPtr<CSSValue> selectedCSSValue = selectionStyle->style()->getPropertyCSSValue(propertyID);
-    String newStyle = "none";
+    String newStyle = ASCIILiteral("none");
     if (selectedCSSValue->isValueList()) {
         RefPtr<CSSValueList> selectedCSSValueList = static_cast<CSSValueList*>(selectedCSSValue.get());
         if (!selectedCSSValueList->removeAll(value))
index c3507ad0c1c3e788d498453a7be490c59ee25c36..24ec3d5e6ad846fe89984187507ae2abf8f56664 100644 (file)
@@ -54,7 +54,7 @@ static USet* getSmartSet(bool isPreviousCharacter)
     if (!smartSet) {
         // Whitespace and newline (kCFCharacterSetWhitespaceAndNewline)
         UErrorCode ec = U_ZERO_ERROR;
-        String whitespaceAndNewline = "[[:WSpace:] [\\u000A\\u000B\\u000C\\u000D\\u0085]]";
+        String whitespaceAndNewline = ASCIILiteral("[[:WSpace:] [\\u000A\\u000B\\u000C\\u000D\\u0085]]");
         smartSet = uset_openPattern(whitespaceAndNewline.characters(), whitespaceAndNewline.length(), &ec);
         ASSERT(U_SUCCESS(ec));
 
@@ -71,14 +71,14 @@ static USet* getSmartSet(bool isPreviousCharacter)
         uset_addRange(smartSet, 0x2F800, 0x2F800 + 0x021E); // CJK Compatibility Ideographs (0x2F800 - 0x2FA1D)
 
         if (isPreviousCharacter) {
-            addAllCodePoints(smartSet, "([\"\'#$/-`{");
+            addAllCodePoints(smartSet, ASCIILiteral("([\"\'#$/-`{"));
             preSmartSet = smartSet;
         } else {
-            addAllCodePoints(smartSet, ")].,;:?\'!\"%*-/}");
+            addAllCodePoints(smartSet, ASCIILiteral(")].,;:?\'!\"%*-/}"));
 
             // Punctuation (kCFCharacterSetPunctuation)
             UErrorCode ec = U_ZERO_ERROR;
-            String punctuationClass = "[:P:]";
+            String punctuationClass = ASCIILiteral("[:P:]");
             USet* icuPunct = uset_openPattern(punctuationClass.characters(), punctuationClass.length(), &ec);
             ASSERT(U_SUCCESS(ec));
             uset_addAll(smartSet, icuPunct);
index 5d9ba2dee602dd02eb0982d629513bfa9769f288..9af1883f7743d5c302d22bcc514c55c18d1271a4 100644 (file)
@@ -794,7 +794,7 @@ static void fillContainerFromString(ContainerNode* paragraph, const String& stri
 
     Vector<String> tabList;
     string.split('\t', true, tabList);
-    String tabText = "";
+    String tabText = emptyString();
     bool first = true;
     size_t numEntries = tabList.size();
     for (size_t i = 0; i < numEntries; ++i) {
@@ -805,7 +805,7 @@ static void fillContainerFromString(ContainerNode* paragraph, const String& stri
             if (!tabText.isEmpty()) {
                 paragraph->appendChild(createTabSpanElement(document, tabText), ec);
                 ASSERT(!ec);
-                tabText = "";
+                tabText = emptyString();
             }
             RefPtr<Node> textNode = document->createTextNode(stringWithRebalancedWhitespace(s, first, i + 1 == numEntries));
             paragraph->appendChild(textNode.release(), ec);
index 241816ff309c44aa64d27e8c0f729854e22aec56..756c0bb1cf036b485d0b3f5d3fe8b2c6a44348f8 100644 (file)
@@ -29,6 +29,7 @@
 #include "RenderStyle.h"
 #include "StyleInheritedData.h"
 #include "Text.h"
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
@@ -70,14 +71,14 @@ void HTMLTitleElement::childrenChanged(bool changedByParser, Node* beforeChange,
 
 String HTMLTitleElement::text() const
 {
-    String val = "";
-    
+    StringBuilder result;
+
     for (Node *n = firstChild(); n; n = n->nextSibling()) {
         if (n->isTextNode())
-            val += toText(n)->data();
+            result.append(toText(n)->data());
     }
 
-    return val;
+    return result.toString();
 }
 
 StringWithDirection HTMLTitleElement::textWithDirection()
index c12a56b0d0f21d0c48a78aed580dd1dbe97daf14..ac590181fc2c70b55599b8ea8021b3e5294b66e5 100644 (file)
@@ -249,7 +249,7 @@ void InspectorConsoleAgent::didFailLoading(unsigned long identifier, const Resou
         return;
     if (error.isCancellation()) // Report failures only.
         return;
-    String message = "Failed to load resource";
+    String message = ASCIILiteral("Failed to load resource");
     if (!error.localizedDescription().isEmpty())
         message += ": " + error.localizedDescription();
     String requestId = IdentifiersFactory::requestId(identifier);
index 03f78e9888c11c2a042e0501046459c071e6532b..8079997cac87bacade3614ba03cd3fa1fa55791b 100644 (file)
@@ -51,6 +51,7 @@
 #include "SerializedScriptValue.h"
 #include "TextResourceDecoder.h"
 #include "ThreadableLoader.h"
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
@@ -210,20 +211,22 @@ void EventSource::didReceiveResponse(unsigned long, const ResourceResponse& resp
         // If we have a charset, the only allowed value is UTF-8 (case-insensitive).
         responseIsValid = charset.isEmpty() || equalIgnoringCase(charset, "UTF-8");
         if (!responseIsValid) {
-            String message = "EventSource's response has a charset (\"";
-            message += charset;
-            message += "\") that is not UTF-8. Aborting the connection.";
+            StringBuilder message;
+            message.appendLiteral("EventSource's response has a charset (\"");
+            message.append(charset);
+            message.appendLiteral("\") that is not UTF-8. Aborting the connection.");
             // FIXME: We are missing the source line.
-            scriptExecutionContext()->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message);
+            scriptExecutionContext()->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message.toString());
         }
     } else {
         // To keep the signal-to-noise ratio low, we only log 200-response with an invalid MIME type.
         if (statusCode == 200 && !mimeTypeIsValid) {
-            String message = "EventSource's response has a MIME type (\"";
-            message += response.mimeType();
-            message += "\") that is not \"text/event-stream\". Aborting the connection.";
+            StringBuilder message;
+            message.appendLiteral("EventSource's response has a MIME type (\"");
+            message.append(response.mimeType());
+            message.appendLiteral("\") that is not \"text/event-stream\". Aborting the connection.");
             // FIXME: We are missing the source line.
-            scriptExecutionContext()->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message);
+            scriptExecutionContext()->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message.toString());
         }
     }
 
index 732c4df73b68a2119b53424f6dcb50cef8b4c2ca..872bbd718164ab3a8452c3407fcdb9608e8ccf2d 100644 (file)
@@ -66,7 +66,7 @@ static String platformLanguage()
     // getLocale() returns a POSIX locale which uses '_' to separate language and country.
     // However, we use '-' instead of '_' in WebCore (e.g. en_us should read en-us)
     size_t underscorePosition = lang.find('_');
-    String replaceWith = "-";
+    String replaceWith = ASCIILiteral("-");
     if (underscorePosition != notFound)
         return lang.replace(underscorePosition, replaceWith.length(), replaceWith);
     return lang;
index 083e882e9917cf036256e8eb1db298337702204f..2ae3fe7870ae4722d431f00509e076896fc09c7d 100644 (file)
@@ -35,6 +35,7 @@
 #include "RotateTransformOperation.h"
 #include "TextStream.h"
 #include <wtf/text/CString.h>
+#include <wtf/text/StringBuilder.h>
 #include <wtf/text/WTFString.h>
 
 #ifndef NDEBUG
@@ -323,10 +324,11 @@ void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I
 String GraphicsLayer::animationNameForTransition(AnimatedPropertyID property)
 {
     // | is not a valid identifier character in CSS, so this can never conflict with a keyframe identifier.
-    String id = "-|transition";
+    StringBuilder id;
+    id.appendLiteral("-|transition");
     id.append(static_cast<char>(property));
     id.append('-');
-    return id;
+    return id.toString();
 }
 
 void GraphicsLayer::suspendAnimations(double)
index 6af6bc42154a9278006ea9970c00889dd46c0010..dbab969e8d8b7c3975e6d67d8cf03a72dd06e8d9 100644 (file)
@@ -230,6 +230,8 @@ String RSSAtomParser::parseContent(const String& base, xmlNode* node)
     // See: http://tools.ietf.org/html/rfc4287#page-16
 
     BLACKBERRY_ASSERT(node);
+    // Why does Blackberry have its own RSS parser?
+    // FIXME: content should be a StringBuilder.
     String content;
     String type = "default";
     String src;
index 3fd3d023d094e2b1c65d2776fb2ca89ce88f0f54..8ab626b12afacf6922d7d7bfb2882f365d24d0f0 100644 (file)
@@ -93,7 +93,7 @@ bool SQLiteDatabase::open(const String& filename, bool forWebSQLDatabase)
     else
         m_openErrorMessage = "sqlite_open returned null";
 
-    if (!SQLiteStatement(*this, "PRAGMA temp_store = MEMORY;").executeCommand())
+    if (!SQLiteStatement(*this, ASCIILiteral("PRAGMA temp_store = MEMORY;")).executeCommand())
         LOG_ERROR("SQLite database could not set temp_store to memory");
 
     return isOpen();
@@ -140,9 +140,9 @@ bool SQLiteDatabase::isInterrupted()
 void SQLiteDatabase::setFullsync(bool fsync) 
 {
     if (fsync) 
-        executeCommand("PRAGMA fullfsync = 1;");
+        executeCommand(ASCIILiteral("PRAGMA fullfsync = 1;"));
     else
-        executeCommand("PRAGMA fullfsync = 0;");
+        executeCommand(ASCIILiteral("PRAGMA fullfsync = 0;"));
 }
 
 int64_t SQLiteDatabase::maximumSize()
@@ -152,7 +152,7 @@ int64_t SQLiteDatabase::maximumSize()
     {
         MutexLocker locker(m_authorizerLock);
         enableAuthorizer(false);
-        SQLiteStatement statement(*this, "PRAGMA max_page_count");
+        SQLiteStatement statement(*this, ASCIILiteral("PRAGMA max_page_count"));
         maxPageCount = statement.getColumnInt64(0);
         enableAuthorizer(true);
     }
@@ -194,7 +194,7 @@ int SQLiteDatabase::pageSize()
         MutexLocker locker(m_authorizerLock);
         enableAuthorizer(false);
         
-        SQLiteStatement statement(*this, "PRAGMA page_size");
+        SQLiteStatement statement(*this, ASCIILiteral("PRAGMA page_size"));
         m_pageSize = statement.getColumnInt(0);
         
         enableAuthorizer(true);
@@ -211,7 +211,7 @@ int64_t SQLiteDatabase::freeSpaceSize()
         MutexLocker locker(m_authorizerLock);
         enableAuthorizer(false);
         // Note: freelist_count was added in SQLite 3.4.1.
-        SQLiteStatement statement(*this, "PRAGMA freelist_count");
+        SQLiteStatement statement(*this, ASCIILiteral("PRAGMA freelist_count"));
         freelistCount = statement.getColumnInt64(0);
         enableAuthorizer(true);
     }
@@ -226,7 +226,7 @@ int64_t SQLiteDatabase::totalSize()
     {
         MutexLocker locker(m_authorizerLock);
         enableAuthorizer(false);
-        SQLiteStatement statement(*this, "PRAGMA page_count");
+        SQLiteStatement statement(*this, ASCIILiteral("PRAGMA page_count"));
         pageCount = statement.getColumnInt64(0);
         enableAuthorizer(true);
     }
@@ -269,9 +269,9 @@ bool SQLiteDatabase::tableExists(const String& tablename)
 {
     if (!isOpen())
         return false;
-        
+
     String statement = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = '" + tablename + "';";
-    
+
     SQLiteStatement sql(*this, statement);
     sql.prepare();
     return sql.step() == SQLITE_ROW;
@@ -279,7 +279,7 @@ bool SQLiteDatabase::tableExists(const String& tablename)
 
 void SQLiteDatabase::clearAllTables()
 {
-    String query = "SELECT name FROM sqlite_master WHERE type='table';";
+    String query = ASCIILiteral("SELECT name FROM sqlite_master WHERE type='table';");
     Vector<String> tables;
     if (!SQLiteStatement(*this, query).returnTextResults(0, tables)) {
         LOG(SQLDatabase, "Unable to retrieve list of tables from database");
@@ -296,7 +296,7 @@ void SQLiteDatabase::clearAllTables()
 
 int SQLiteDatabase::runVacuumCommand()
 {
-    if (!executeCommand("VACUUM;"))
+    if (!executeCommand(ASCIILiteral("VACUUM;")))
         LOG(SQLDatabase, "Unable to vacuum database - %s", lastErrorMsg());
     return lastError();
 }
@@ -306,7 +306,7 @@ int SQLiteDatabase::runIncrementalVacuumCommand()
     MutexLocker locker(m_authorizerLock);
     enableAuthorizer(false);
 
-    if (!executeCommand("PRAGMA incremental_vacuum"))
+    if (!executeCommand(ASCIILiteral("PRAGMA incremental_vacuum")))
         LOG(SQLDatabase, "Unable to run incremental vacuum - %s", lastErrorMsg());
 
     enableAuthorizer(true);
@@ -457,7 +457,7 @@ bool SQLiteDatabase::isAutoCommitOn() const
 
 bool SQLiteDatabase::turnOnIncrementalAutoVacuum()
 {
-    SQLiteStatement statement(*this, "PRAGMA auto_vacuum");
+    SQLiteStatement statement(*this, ASCIILiteral("PRAGMA auto_vacuum"));
     int autoVacuumMode = statement.getColumnInt(0);
     int error = lastError();
 
@@ -474,10 +474,10 @@ bool SQLiteDatabase::turnOnIncrementalAutoVacuum()
     case AutoVacuumIncremental:
         return true;
     case AutoVacuumFull:
-        return executeCommand("PRAGMA auto_vacuum = 2");
+        return executeCommand(ASCIILiteral("PRAGMA auto_vacuum = 2"));
     case AutoVacuumNone:
     default:
-        if (!executeCommand("PRAGMA auto_vacuum = 2"))
+        if (!executeCommand(ASCIILiteral("PRAGMA auto_vacuum = 2")))
             return false;
         runVacuumCommand();
         error = lastError();
index ee0255e12858ea39b1bc94665129073c4dca194d..0ab0d72832f486b74ddb980e1c9b4d6ec612eaa3 100644 (file)
@@ -198,7 +198,7 @@ String directoryName(const String& path)
 
 static String bundleName()
 {
-    static String name = "WebKit";
+    DEFINE_STATIC_LOCAL(String, name, (ASCIILiteral("WebKit")));
 
 #if USE(CF)
     static bool initialized;
@@ -224,7 +224,7 @@ static String storageDirectory(DWORD pathIdentifier)
     buffer.resize(wcslen(buffer.data()));
     String directory = String::adopt(buffer);
 
-    static const String companyNameDirectory = "Apple Computer\\";
+    DEFINE_STATIC_LOCAL(String, companyNameDirectory, (ASCIILiteral("Apple Computer\\")));
     directory = pathByAppendingComponent(directory, companyNameDirectory + bundleName());
     if (!makeAllDirectories(directory))
         return String();
index 002380f5f953f9bee2c565e9ca5c132ad4c0af4a..085a318b421a7ad8fdfc670b63d31af82e266e52 100644 (file)
@@ -140,7 +140,7 @@ void PluginStream::startStream()
 
     if (m_resourceResponse.isHTTP()) {
         StringBuilder stringBuilder;
-        String separator(": ");
+        String separator = ASCIILiteral(": ");
 
         String statusLine = "HTTP " + String::number(m_resourceResponse.httpStatusCode()) + " OK\n";
         stringBuilder.append(statusLine);
index 5b79d6c90cb6375360b12e312fd377ac3d438b40..06367c7268df445798e41007715db373036f2ac1 100644 (file)
@@ -212,7 +212,7 @@ void RenderMenuList::setTextFromOption(int optionIndex)
     int size = listItems.size();
 
     int i = select->optionToListIndex(optionIndex);
-    String text = "";
+    String text = emptyString();
     if (i >= 0 && i < size) {
         Element* element = listItems[i];
         if (element->hasTagName(optionTag)) {