This source file includes following definitions.
- addJavaScriptString
- addProperty
- addProperty
- addProperty
- addProperty
- addProperty
- addProperty
#include "config.h"
#include "core/page/PagePopupClient.h"
#include "wtf/text/StringBuilder.h"
namespace WebCore {
#define addLiteral(literal, data) data->append(literal, sizeof(literal) - 1)
void PagePopupClient::addJavaScriptString(const String& str, SharedBuffer* data)
{
addLiteral("\"", data);
StringBuilder builder;
builder.reserveCapacity(str.length());
for (unsigned i = 0; i < str.length(); ++i) {
if (str[i] == '\\' || str[i] == '"')
builder.append('\\');
builder.append(str[i]);
}
addString(builder.toString(), data);
addLiteral("\"", data);
}
void PagePopupClient::addProperty(const char* name, const String& value, SharedBuffer* data)
{
data->append(name, strlen(name));
addLiteral(": ", data);
addJavaScriptString(value, data);
addLiteral(",\n", data);
}
void PagePopupClient::addProperty(const char* name, int value, SharedBuffer* data)
{
data->append(name, strlen(name));
addLiteral(": ", data);
addString(String::number(value), data);
addLiteral(",\n", data);
}
void PagePopupClient::addProperty(const char* name, unsigned value, SharedBuffer* data)
{
data->append(name, strlen(name));
addLiteral(": ", data);
addString(String::number(value), data);
addLiteral(",\n", data);
}
void PagePopupClient::addProperty(const char* name, bool value, SharedBuffer* data)
{
data->append(name, strlen(name));
addLiteral(": ", data);
if (value)
addLiteral("true", data);
else
addLiteral("false", data);
addLiteral(",\n", data);
}
void PagePopupClient::addProperty(const char* name, const Vector<String>& values, SharedBuffer* data)
{
data->append(name, strlen(name));
addLiteral(": [", data);
for (unsigned i = 0; i < values.size(); ++i) {
if (i)
addLiteral(",", data);
addJavaScriptString(values[i], data);
}
addLiteral("],\n", data);
}
void PagePopupClient::addProperty(const char* name, const IntRect& rect, SharedBuffer* data)
{
data->append(name, strlen(name));
addLiteral(": {", data);
addProperty("x", rect.x(), data);
addProperty("y", rect.y(), data);
addProperty("width", rect.width(), data);
addProperty("height", rect.height(), data);
addLiteral("},\n", data);
}
}