Diff
Modified: trunk/Source/WebCore/ChangeLog (127223 => 127224)
--- trunk/Source/WebCore/ChangeLog 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/ChangeLog 2012-08-31 01:25:43 UTC (rev 127224)
@@ -1,3 +1,60 @@
+2012-08-30 Adam Barth <[email protected]>
+
+ Replace more instances of += with StringBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=95502
+
+ Reviewed by Darin Adler.
+
+ This patch removes many uses of WTF::String::operator+= in WebCore.
+ Many of these uses are inefficient because they cause us to allocate
+ and memcpy strings more times than necessary. In most cases, I've
+ replaced these inefficient patterns with StringBuilder.
+
+ This patch makes progress towards removing WTF::String::operator+= from
+ the project.
+
+ We can make cssText() more efficient by passing a single StringBuilder
+ instance along to the recursive calls, but I've left that for a later
+ patch.
+
+ * css/CSSBorderImageSliceValue.cpp:
+ (WebCore::CSSBorderImageSliceValue::customCssText):
+ * css/CSSFontFaceSrcValue.cpp:
+ (WebCore::CSSFontFaceSrcValue::customCssText):
+ * css/CSSFunctionValue.cpp:
+ (WebCore::CSSFunctionValue::customCssText):
+ * css/CSSGradientValue.cpp:
+ (WebCore::CSSLinearGradientValue::customCssText):
+ (WebCore::CSSRadialGradientValue::customCssText):
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::createKeyframe):
+ * css/CSSPrimitiveValue.cpp:
+ (WebCore::CSSPrimitiveValue::customCssText):
+ * css/CSSReflectValue.cpp:
+ (WebCore::CSSReflectValue::customCssText):
+ * css/CSSTimingFunctionValue.cpp:
+ (WebCore::CSSCubicBezierTimingFunctionValue::customCssText):
+ (WebCore::CSSStepsTimingFunctionValue::customCssText):
+ * css/StylePropertySet.cpp:
+ (WebCore::StylePropertySet::get4Values):
+ (WebCore::StylePropertySet::getLayeredShorthandValue):
+ (WebCore::StylePropertySet::getShorthandValue):
+ * fileapi/BlobURL.cpp:
+ (WebCore::BlobURL::createBlobURL):
+ * inspector/InspectorCSSAgent.cpp:
+ (WebCore::InspectorCSSAgent::SetPropertyTextAction::redo):
+ * inspector/InspectorClient.cpp:
+ (WebCore::InspectorClient::doDispatchMessageOnFrontendPage):
+ * inspector/InspectorConsoleAgent.cpp:
+ (WebCore::InspectorConsoleAgent::didFailLoading):
+ * inspector/InspectorFileSystemAgent.cpp:
+ (WebCore):
+ * inspector/InspectorPageAgent.cpp:
+ (WebCore::InspectorPageAgent::cachedResourceContent):
+ (WebCore::InspectorPageAgent::getCookies):
+ * inspector/InspectorStyleSheet.cpp:
+ (WebCore::InspectorStyleSheet::addRule):
+
2012-08-30 Luke Macpherson <[email protected]>
Make it possible to use CSS Variables inside Calc expressions.
Modified: trunk/Source/WebCore/css/CSSBorderImageSliceValue.cpp (127223 => 127224)
--- trunk/Source/WebCore/css/CSSBorderImageSliceValue.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/css/CSSBorderImageSliceValue.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -46,7 +46,7 @@
// Now the fill keywords if it is present.
if (m_fill)
- text += " fill";
+ return text + " fill";
return text;
}
Modified: trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp (127223 => 127224)
--- trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -33,6 +33,7 @@
#include "Node.h"
#include "SVGFontFaceElement.h"
#include "StyleSheetContents.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -63,16 +64,19 @@
String CSSFontFaceSrcValue::customCssText() const
{
- String result;
+ StringBuilder result;
if (isLocal())
- result += "local(";
+ result.appendLiteral("local(");
else
- result += "url(";
- result += m_resource;
- result += ")";
- if (!m_format.isEmpty())
- result += " format(" + m_format + ")";
- return result;
+ result.appendLiteral("url(");
+ result.append(m_resource);
+ result.append(')');
+ if (!m_format.isEmpty()) {
+ result.appendLiteral(" format(");
+ result.append(m_format);
+ result.append(')');
+ }
+ return result.toString();
}
void CSSFontFaceSrcValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
Modified: trunk/Source/WebCore/css/CSSFunctionValue.cpp (127223 => 127224)
--- trunk/Source/WebCore/css/CSSFunctionValue.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/css/CSSFunctionValue.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -30,6 +30,7 @@
#include "CSSValueList.h"
#include "MemoryInstrumentation.h"
#include <wtf/PassOwnPtr.h>
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -43,11 +44,12 @@
String CSSFunctionValue::customCssText() const
{
- String result = m_name; // Includes the '('
+ StringBuilder result;
+ result.append(m_name); // Includes the '('
if (m_args)
- result += m_args->cssText();
- result += ")";
- return result;
+ result.append(m_args->cssText());
+ result.append(')');
+ return result.toString();
}
void CSSFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
Modified: trunk/Source/WebCore/css/CSSGradientValue.cpp (127223 => 127224)
--- trunk/Source/WebCore/css/CSSGradientValue.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/css/CSSGradientValue.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -38,6 +38,7 @@
#include "PlatformString.h"
#include "RenderObject.h"
#include "StyleResolver.h"
+#include <wtf/text/StringBuilder.h>
using namespace std;
@@ -473,51 +474,71 @@
String CSSLinearGradientValue::customCssText() const
{
- String result;
+ StringBuilder result;
if (m_deprecatedType) {
- result = "-webkit-gradient(linear, ";
- result += m_firstX->cssText() + " ";
- result += m_firstY->cssText() + ", ";
- result += m_secondX->cssText() + " ";
- result += m_secondY->cssText();
+ result.appendLiteral("-webkit-gradient(linear, ");
+ result.append(m_firstX->cssText());
+ result.append(' ');
+ result.append(m_firstY->cssText());
+ result.appendLiteral(", ");
+ result.append(m_secondX->cssText());
+ result.append(' ');
+ result.append(m_secondY->cssText());
for (unsigned i = 0; i < m_stops.size(); i++) {
const CSSGradientColorStop& stop = m_stops[i];
- result += ", ";
- if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0)
- result += "from(" + stop.m_color->cssText() + ")";
- else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1)
- result += "to(" + stop.m_color->cssText() + ")";
- else
- result += "color-stop(" + String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)) + ", " + stop.m_color->cssText() + ")";
+ result.appendLiteral(", ");
+ if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) {
+ result.appendLiteral("from(");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) {
+ result.appendLiteral("to(");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ } else {
+ result.appendLiteral("color-stop(");
+ result.append(String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)));
+ result.appendLiteral(", ");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ }
}
} else {
- result = m_repeating ? "-webkit-repeating-linear-gradient(" : "-webkit-linear-gradient(";
+ if (m_repeating)
+ result.appendLiteral("-webkit-repeating-linear-gradient(");
+ else
+ result.appendLiteral("-webkit-linear-gradient(");
+
if (m_angle)
- result += m_angle->cssText();
+ result.append(m_angle->cssText());
else {
- if (m_firstX && m_firstY)
- result += m_firstX->cssText() + " " + m_firstY->cssText();
- else if (m_firstX || m_firstY) {
+ if (m_firstX && m_firstY) {
+ result.append(m_firstX->cssText());
+ result.append(' ');
+ result.append(m_firstY->cssText());
+ } else if (m_firstX || m_firstY) {
if (m_firstX)
- result += m_firstX->cssText();
+ result.append(m_firstX->cssText());
if (m_firstY)
- result += m_firstY->cssText();
+ result.append(m_firstY->cssText());
}
}
for (unsigned i = 0; i < m_stops.size(); i++) {
const CSSGradientColorStop& stop = m_stops[i];
- result += ", ";
- result += stop.m_color->cssText();
- if (stop.m_position)
- result += " " + stop.m_position->cssText();
+ result.appendLiteral(", ");
+ result.append(stop.m_color->cssText());
+ if (stop.m_position) {
+ result.append(' ');
+ result.append(stop.m_position->cssText());
+ }
}
}
- result += ")";
- return result;
+ result.append(')');
+ return result.toString();
}
// Compute the endpoints so that a gradient of the given angle covers a box of the given size.
@@ -622,71 +643,92 @@
String CSSRadialGradientValue::customCssText() const
{
- String result;
+ StringBuilder result;
if (m_deprecatedType) {
- result = "-webkit-gradient(radial, ";
+ result.appendLiteral("-webkit-gradient(radial, ");
+ result.append(m_firstX->cssText());
+ result.append(' ');
+ result.append(m_firstY->cssText());
+ result.appendLiteral(", ");
+ result.append(m_firstRadius->cssText());
+ result.appendLiteral(", ");
+ result.append(m_secondX->cssText());
+ result.append(' ');
+ result.append(m_secondY->cssText());
+ result.appendLiteral(", ");
+ result.append(m_secondRadius->cssText());
- result += m_firstX->cssText() + " ";
- result += m_firstY->cssText() + ", ";
- result += m_firstRadius->cssText() + ", ";
- result += m_secondX->cssText() + " ";
- result += m_secondY->cssText();
- result += ", ";
- result += m_secondRadius->cssText();
-
// FIXME: share?
for (unsigned i = 0; i < m_stops.size(); i++) {
const CSSGradientColorStop& stop = m_stops[i];
- result += ", ";
- if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0)
- result += "from(" + stop.m_color->cssText() + ")";
- else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1)
- result += "to(" + stop.m_color->cssText() + ")";
- else
- result += "color-stop(" + String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)) + ", " + stop.m_color->cssText() + ")";
+ result.appendLiteral(", ");
+ if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) {
+ result.appendLiteral("from(");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) {
+ result.appendLiteral("to(");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ } else {
+ result.appendLiteral("color-stop(");
+ result.append(String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)));
+ result.appendLiteral(", ");
+ result.append(stop.m_color->cssText());
+ result.append(')');
+ }
}
} else {
+ if (m_repeating)
+ result.appendLiteral("-webkit-repeating-radial-gradient(");
+ else
+ result.appendLiteral("-webkit-radial-gradient(");
- result = m_repeating ? "-webkit-repeating-radial-gradient(" : "-webkit-radial-gradient(";
if (m_firstX && m_firstY) {
- result += m_firstX->cssText() + " " + m_firstY->cssText();
+ result.append(m_firstX->cssText());
+ result.append(' ');
+ result.append(m_firstY->cssText());
} else if (m_firstX)
- result += m_firstX->cssText();
+ result.append(m_firstX->cssText());
else if (m_firstY)
- result += m_firstY->cssText();
+ result.append(m_firstY->cssText());
else
- result += "center";
+ result.appendLiteral("center");
-
if (m_shape || m_sizingBehavior) {
- result += ", ";
- if (m_shape)
- result += m_shape->cssText() + " ";
- else
- result += "ellipse ";
+ result.appendLiteral(", ");
+ if (m_shape) {
+ result.append(m_shape->cssText());
+ result.append(' ');
+ } else
+ result.appendLiteral("ellipse ");
if (m_sizingBehavior)
- result += m_sizingBehavior->cssText();
+ result.append(m_sizingBehavior->cssText());
else
- result += "cover";
+ result.appendLiteral("cover");
} else if (m_endHorizontalSize && m_endVerticalSize) {
- result += ", ";
- result += m_endHorizontalSize->cssText() + " " + m_endVerticalSize->cssText();
+ result.appendLiteral(", ");
+ result.append(m_endHorizontalSize->cssText());
+ result.append(' ');
+ result.append(m_endVerticalSize->cssText());
}
for (unsigned i = 0; i < m_stops.size(); i++) {
const CSSGradientColorStop& stop = m_stops[i];
- result += ", ";
- result += stop.m_color->cssText();
- if (stop.m_position)
- result += " " + stop.m_position->cssText();
+ result.appendLiteral(", ");
+ result.append(stop.m_color->cssText());
+ if (stop.m_position) {
+ result.append(' ');
+ result.append(stop.m_position->cssText());
+ }
}
}
- result += ")";
- return result;
+ result.append(')');
+ return result.toString();
}
float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, RenderStyle* style, RenderStyle* rootStyle, float* widthOrHeight)
Modified: trunk/Source/WebCore/css/CSSParser.cpp (127223 => 127224)
--- trunk/Source/WebCore/css/CSSParser.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -9953,17 +9953,17 @@
StyleKeyframe* CSSParser::createKeyframe(CSSParserValueList* keys)
{
// Create a key string from the passed keys
- String keyString;
+ StringBuilder keyString;
for (unsigned i = 0; i < keys->size(); ++i) {
float key = static_cast<float>(keys->valueAt(i)->fValue);
if (i != 0)
- keyString += ",";
- keyString += String::number(key);
- keyString += "%";
+ keyString.append(',');
+ keyString.append(String::number(key));
+ keyString.append('%');
}
RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create();
- keyframe->setKeyText(keyString);
+ keyframe->setKeyText(keyString.toString());
keyframe->setProperties(createStylePropertySet());
clearProperties();
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (127223 => 127224)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -952,9 +952,7 @@
break;
}
case CSS_COUNTER_NAME:
- text = "counter(";
- text += m_value.string;
- text += ")";
+ text = "counter(" + String(m_value.string) + ')';
break;
case CSS_COUNTER: {
StringBuilder result;
@@ -1038,30 +1036,34 @@
text = String::adopt(result);
break;
}
- case CSS_PAIR:
- text = m_value.pair->first()->cssText();
+ case CSS_PAIR: {
+ StringBuilder result;
+ result.append(m_value.pair->first()->cssText());
if (m_value.pair->second() != m_value.pair->first()) {
- text += " ";
- text += m_value.pair->second()->cssText();
+ result.append(' ');
+ result.append(m_value.pair->second()->cssText());
}
+ text = result.toString();
break;
+ }
#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(WIDGET_REGION)
- case CSS_DASHBOARD_REGION:
+ case CSS_DASHBOARD_REGION: {
+ StringBuilder result;
for (DashboardRegion* region = getDashboardRegionValue(); region; region = region->m_next.get()) {
- if (!text.isEmpty())
- text.append(' ');
+ if (!result.isEmpty())
+ result.append(' ');
#if ENABLE(DASHBOARD_SUPPORT) && ENABLE(WIDGET_REGION)
- text += region->m_cssFunctionName;
+ result.append(region->m_cssFunctionName);
#elif ENABLE(DASHBOARD_SUPPORT)
- text += "dashboard-region(";
+ result.appendLiteral("dashboard-region(");
#else
- text += "region(";
+ result.appendLiteral("region(");
#endif
- text += region->m_label;
+ result.append(region->m_label);
if (region->m_isCircle)
- text += " circle";
+ result.appendLiteral(" circle");
else if (region->m_isRectangle)
- text += " rectangle";
+ result.appendLiteral(" rectangle");
else
break;
if (region->top()->m_primitiveUnitType == CSS_IDENT && region->top()->getIdent() == CSSValueInvalid) {
@@ -1072,15 +1074,20 @@
ASSERT(region->bottom()->getIdent() == CSSValueInvalid);
ASSERT(region->left()->getIdent() == CSSValueInvalid);
} else {
- text.append(' ');
- text += region->top()->cssText() + " ";
- text += region->right()->cssText() + " ";
- text += region->bottom()->cssText() + " ";
- text += region->left()->cssText();
+ result.append(' ');
+ result.append(region->top()->cssText());
+ result.append(' ');
+ result.append(region->right()->cssText());
+ result.append(' ');
+ result.append(region->bottom()->cssText());
+ result.append(' ');
+ result.append(region->left()->cssText());
}
- text += ")";
+ result.append(')');
}
+ text = result.toString();
break;
+ }
#endif
case CSS_PARSER_OPERATOR: {
char c = static_cast<char>(m_value.ident);
@@ -1107,9 +1114,7 @@
break;
#if ENABLE(CSS_VARIABLES)
case CSS_VARIABLE_NAME:
- text = "-webkit-var(";
- text += m_value.string;
- text += ")";
+ text = "-webkit-var(" + String(m_value.string) + ")";
break;
#endif
}
Modified: trunk/Source/WebCore/css/CSSReflectValue.cpp (127223 => 127224)
--- trunk/Source/WebCore/css/CSSReflectValue.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/css/CSSReflectValue.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -29,6 +29,7 @@
#include "CSSPrimitiveValue.h"
#include "MemoryInstrumentation.h"
#include "PlatformString.h"
+#include <wtf/text/StringBuilder.h>
using namespace std;
@@ -36,28 +37,29 @@
String CSSReflectValue::customCssText() const
{
- String result;
+ StringBuilder result;
switch (m_direction) {
case ReflectionBelow:
- result += "below ";
+ result.appendLiteral("below ");
break;
case ReflectionAbove:
- result += "above ";
+ result.appendLiteral("above ");
break;
case ReflectionLeft:
- result += "left ";
+ result.appendLiteral("left ");
break;
case ReflectionRight:
- result += "right ";
+ result.appendLiteral("right ");
break;
default:
break;
}
- result += m_offset->cssText() + " ";
+ result.append(m_offset->cssText());
+ result.append(' ');
if (m_mask)
- result += m_mask->cssText();
- return result;
+ result.append(m_mask->cssText());
+ return result.toString();
}
void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
Modified: trunk/Source/WebCore/css/CSSTimingFunctionValue.cpp (127223 => 127224)
--- trunk/Source/WebCore/css/CSSTimingFunctionValue.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/css/CSSTimingFunctionValue.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -43,16 +43,11 @@
String CSSCubicBezierTimingFunctionValue::customCssText() const
{
- String text("cubic-bezier(");
- text += String::number(m_x1);
- text += ", ";
- text += String::number(m_y1);
- text += ", ";
- text += String::number(m_x2);
- text += ", ";
- text += String::number(m_y2);
- text += ")";
- return text;
+ return "cubic-bezier("
+ + String::number(m_x1) + ", "
+ + String::number(m_y1) + ", "
+ + String::number(m_x2) + ", "
+ + String::number(m_y2) + ")";
}
void CSSCubicBezierTimingFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
@@ -62,12 +57,7 @@
String CSSStepsTimingFunctionValue::customCssText() const
{
- String text("steps(");
- text += String::number(m_steps);
- text += ", ";
- text += m_stepAtStart ? "start" : "end";
- text += ")";
- return text;
+ return "steps(" + String::number(m_steps) + ", " + (m_stepAtStart ? "start" : "end") + ')';
}
void CSSStepsTimingFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
Modified: trunk/Source/WebCore/fileapi/BlobURL.cpp (127223 => 127224)
--- trunk/Source/WebCore/fileapi/BlobURL.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/fileapi/BlobURL.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -72,11 +72,7 @@
KURL BlobURL::createBlobURL(const String& originString)
{
ASSERT(!originString.isEmpty());
- String urlString = kBlobProtocol;
- urlString += ":";
- urlString += encodeWithURLEscapeSequences(originString);
- urlString += "/";
- urlString += createCanonicalUUIDString();
+ String urlString = "blob:" + encodeWithURLEscapeSequences(originString) + '/' + createCanonicalUUIDString();
return KURL(ParsedURLString, urlString);
}
Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (127223 => 127224)
--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -326,7 +326,7 @@
m_oldText = oldText.stripWhiteSpace();
// FIXME: remove this once the model handles this case.
if (!m_oldText.endsWith(';'))
- m_oldText += ";";
+ m_oldText.append(';');
return result;
}
Modified: trunk/Source/WebCore/inspector/InspectorClient.cpp (127223 => 127224)
--- trunk/Source/WebCore/inspector/InspectorClient.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/inspector/InspectorClient.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -55,9 +55,7 @@
if (!scriptController)
return false;
- String dispatchToFrontend("WebInspector.dispatchMessageFromBackend(");
- dispatchToFrontend += message;
- dispatchToFrontend += ");";
+ String dispatchToFrontend = "WebInspector.dispatchMessageFromBackend(" + message + ");";
// FIXME: This should execute the script in the appropriate world.
scriptController->evaluate(ScriptSourceCode(dispatchToFrontend));
Modified: trunk/Source/WebCore/inspector/InspectorConsoleAgent.cpp (127223 => 127224)
--- trunk/Source/WebCore/inspector/InspectorConsoleAgent.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/inspector/InspectorConsoleAgent.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -47,6 +47,7 @@
#include <wtf/CurrentTime.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
+#include <wtf/text/StringBuilder.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -249,11 +250,14 @@
return;
if (error.isCancellation()) // Report failures only.
return;
- String message = ASCIILiteral("Failed to load resource");
- if (!error.localizedDescription().isEmpty())
- message += ": " + error.localizedDescription();
+ StringBuilder message;
+ message.appendLiteral("Failed to load resource");
+ if (!error.localizedDescription().isEmpty()) {
+ message.appendLiteral(": ");
+ message.append(error.localizedDescription());
+ }
String requestId = IdentifiersFactory::requestId(identifier);
- addConsoleMessage(adoptPtr(new ConsoleMessage(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message, error.failingURL(), requestId)));
+ addConsoleMessage(adoptPtr(new ConsoleMessage(NetworkMessageSource, LogMessageType, ErrorMessageLevel, message.toString(), error.failingURL(), requestId)));
}
void InspectorConsoleAgent::setMonitoringXHREnabled(ErrorString*, bool enabled)
Modified: trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp (127223 => 127224)
--- trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -582,7 +582,7 @@
RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create(m_mimeType, m_charset, true);
String result = decoder->decode(static_cast<char*>(buffer->data()), buffer->byteLength());
- result += decoder->flush();
+ result.append(decoder->flush());
m_charset = decoder->encoding().domName();
reportResult(static_cast<FileError::ErrorCode>(0), &result, &m_charset);
}
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (127223 => 127224)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -74,11 +74,11 @@
#include "TextEncoding.h"
#include "TextResourceDecoder.h"
#include "UserGestureIndicator.h"
-
#include <wtf/CurrentTime.h>
#include <wtf/ListHashSet.h>
#include <wtf/Vector.h>
#include <wtf/text/Base64.h>
+#include <wtf/text/StringBuilder.h>
using namespace std;
@@ -197,8 +197,7 @@
if (!decoder)
return false;
String content = decoder->decode(buffer->data(), buffer->size());
- content += decoder->flush();
- *result = content;
+ *result = content + decoder->flush();
return true;
}
default:
@@ -503,7 +502,7 @@
ListHashSet<Cookie> rawCookiesList;
// If we can't get raw cookies - fall back to String representation
- String stringCookiesList;
+ StringBuilder stringCookiesList;
// Return value to getRawCookies should be the same for every call because
// the return value is platform/network backend specific, and the call will
@@ -519,7 +518,7 @@
if (!rawCookiesImplemented) {
// FIXME: We need duplication checking for the String representation of cookies.
ExceptionCode ec = 0;
- stringCookiesList += document->cookie(ec);
+ stringCookiesList.append(document->cookie(ec));
// Exceptions are thrown by cookie() in sandboxed frames. That won't happen here
// because "document" is the document of the main frame of the page.
ASSERT(!ec);
@@ -539,7 +538,7 @@
*cookiesString = "";
} else {
cookies = TypeBuilder::Array<TypeBuilder::Page::Cookie>::create();
- *cookiesString = stringCookiesList;
+ *cookiesString = stringCookiesList.toString();
}
}
Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (127223 => 127224)
--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2012-08-31 01:19:06 UTC (rev 127223)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2012-08-31 01:25:43 UTC (rev 127224)
@@ -801,12 +801,14 @@
CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionCode& ec)
{
- String styleSheetText;
- bool success = getText(&styleSheetText);
+ String text;
+ bool success = getText(&text);
if (!success) {
ec = NOT_FOUND_ERR;
return 0;
}
+ StringBuilder styleSheetText;
+ styleSheetText.append(text);
m_pageStyleSheet->addRule(selector, "", ec);
if (ec)
@@ -815,13 +817,13 @@
CSSStyleRule* rule = InspectorCSSAgent::asCSSStyleRule(m_pageStyleSheet->item(m_pageStyleSheet->length() - 1));
ASSERT(rule);
- if (styleSheetText.length())
- styleSheetText += "\n";
+ if (!styleSheetText.isEmpty())
+ styleSheetText.append('\n');
- styleSheetText += selector;
- styleSheetText += " {}";
+ styleSheetText.append(selector);
+ styleSheetText.appendLiteral(" {}");
// Using setText() as this operation changes the style sheet rule set.
- setText(styleSheetText);
+ setText(styleSheetText.toString());
fireStyleSheetChanged();