Title: [128647] trunk/Source/WebCore
- Revision
- 128647
- Author
- rwlb...@webkit.org
- Date
- 2012-09-14 13:18:08 -0700 (Fri, 14 Sep 2012)
Log Message
[BlackBerry] Use StringBuilder more in BlackBerry RSS classes
https://bugs.webkit.org/show_bug.cgi?id=96820
Reviewed by Antonio Gomes.
Use append/appendLiteral where possible.
* platform/MIMETypeRegistry.cpp:
(WebCore::mimeTypeAssociationMap):
* platform/network/blackberry/rss/RSSAtomParser.cpp:
(WebCore::RSSAtomParser::parseContent):
(WebCore::RSSAtomParser::parseAuthor):
* platform/network/blackberry/rss/RSSGenerator.cpp:
(WebCore::RSSGenerator::generateHtml):
* platform/network/blackberry/rss/RSSParserBase.cpp:
(WebCore::textFromXMLAttr):
(WebCore::textFromXMLNode):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (128646 => 128647)
--- trunk/Source/WebCore/ChangeLog 2012-09-14 20:08:09 UTC (rev 128646)
+++ trunk/Source/WebCore/ChangeLog 2012-09-14 20:18:08 UTC (rev 128647)
@@ -1,3 +1,23 @@
+2012-09-14 Rob Buis <rb...@rim.com>
+
+ [BlackBerry] Use StringBuilder more in BlackBerry RSS classes
+ https://bugs.webkit.org/show_bug.cgi?id=96820
+
+ Reviewed by Antonio Gomes.
+
+ Use append/appendLiteral where possible.
+
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::mimeTypeAssociationMap):
+ * platform/network/blackberry/rss/RSSAtomParser.cpp:
+ (WebCore::RSSAtomParser::parseContent):
+ (WebCore::RSSAtomParser::parseAuthor):
+ * platform/network/blackberry/rss/RSSGenerator.cpp:
+ (WebCore::RSSGenerator::generateHtml):
+ * platform/network/blackberry/rss/RSSParserBase.cpp:
+ (WebCore::textFromXMLAttr):
+ (WebCore::textFromXMLNode):
+
2012-09-14 Alexandru Chiculita <ach...@adobe.com>
[CSS Shaders] Enable anti-aliasing on the FECustomFilter
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (128646 => 128647)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2012-09-14 20:08:09 UTC (rev 128646)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2012-09-14 20:18:08 UTC (rev 128647)
@@ -638,7 +638,7 @@
mimeTypeMap = new MIMETypeAssociationMap;
- mimeTypeMap->add(ASCIILiteral("image/x-ms-bmp"), ASCIILiteral("image/bmp")));
+ mimeTypeMap->add(ASCIILiteral("image/x-ms-bmp"), ASCIILiteral("image/bmp"));
mimeTypeMap->add(ASCIILiteral("image/x-windows-bmp"), ASCIILiteral("image/bmp"));
mimeTypeMap->add(ASCIILiteral("image/x-bmp"), ASCIILiteral("image/bmp"));
mimeTypeMap->add(ASCIILiteral("image/x-bitmap"), ASCIILiteral("image/bmp"));
Modified: trunk/Source/WebCore/platform/network/blackberry/rss/RSSAtomParser.cpp (128646 => 128647)
--- trunk/Source/WebCore/platform/network/blackberry/rss/RSSAtomParser.cpp 2012-09-14 20:08:09 UTC (rev 128646)
+++ trunk/Source/WebCore/platform/network/blackberry/rss/RSSAtomParser.cpp 2012-09-14 20:18:08 UTC (rev 128647)
@@ -22,6 +22,7 @@
#include "BlackBerryPlatformAssert.h"
#include "libxml/parser.h"
#include "libxml/xmlwriter.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -231,7 +232,7 @@
BLACKBERRY_ASSERT(node);
// Why does Blackberry have its own RSS parser?
- // FIXME: content should be a StringBuilder.
+
String content;
String type = "default";
String src;
@@ -248,9 +249,10 @@
if (!src.isEmpty()) {
if (isRelativePath(src))
src = "" + "/" + src;
- content += "<a href=""
- content += src + "\">" + src + "</a>";
- return content;
+ StringBuilder builder;
+ builder.appendLiteral("<a href=""
+ builder.append(src + "\">" + src + "</a>");
+ return builder.toString();
}
if (type == "text" || type.startsWith("text/"))
@@ -263,14 +265,16 @@
if (cur && cur->type == XML_ELEMENT_NODE) {
// Encoding of buffer is utf-8.
xmlNodeDump(buffer, cur->doc, cur, 0, 0);
+ StringBuilder builder;
if (!base.isEmpty()) {
- content += "<base href='' />";
+ builder.appendLiteral("<base href='' />");
}
- content += (const char*)xmlBufferContent(buffer);
+ builder.append((const char*)xmlBufferContent(buffer));
+ content = builder.toString();
}
xmlBufferFree(buffer);
} else if (type.endsWith("+xml") || type.endsWith("/xml"))
@@ -300,9 +304,9 @@
}
if (!email.isEmpty()) {
- username += " (";
- username += email;
- username += ")";
+ username = username + " (";
+ username = username + email;
+ username = username + ")";
}
return username;
Modified: trunk/Source/WebCore/platform/network/blackberry/rss/RSSGenerator.cpp (128646 => 128647)
--- trunk/Source/WebCore/platform/network/blackberry/rss/RSSGenerator.cpp 2012-09-14 20:08:09 UTC (rev 128646)
+++ trunk/Source/WebCore/platform/network/blackberry/rss/RSSGenerator.cpp 2012-09-14 20:18:08 UTC (rev 128647)
@@ -23,6 +23,7 @@
#include "RSSParserBase.h"
#include <wtf/text/CString.h>
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -39,131 +40,131 @@
String RSSGenerator::generateHtml(RSSFeed* feed)
{
- String rc;
- rc += "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />";
- rc += "<meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable= no\">";
- rc += "<title>";
+ StringBuilder builder;
+ builder.appendLiteral("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />");
+ builder.appendLiteral("<meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable= no\">");
+ builder.appendLiteral("<title>");
if (!feed->m_title.isEmpty())
- rc += feed->m_title;
+ builder.append(feed->m_title);
else if (!feed->m_link.isEmpty())
- rc += feed->m_link;
+ builder.append(feed->m_link);
else
- rc += s_defaultFeedTitle;
+ builder.append(s_defaultFeedTitle);
- rc += "</title></head><body>";
+ builder.appendLiteral("</title></head><body>");
- rc += "<h2>";
+ builder.appendLiteral("<h2>");
if (!feed->m_link.isEmpty()) {
- rc += "<a href=""
- rc += feed->m_link;
- rc += "\">";
+ builder.appendLiteral("<a href=""
+ builder.append(feed->m_link);
+ builder.appendLiteral("\">");
}
if (!feed->m_title.isEmpty())
- rc += feed->m_title;
+ builder.append(feed->m_title);
else
- rc += s_defaultFeedTitle;
+ builder.append(s_defaultFeedTitle);
if (!feed->m_link.isEmpty())
- rc += "</a>";
+ builder.appendLiteral("</a>");
- rc += "</h2>";
+ builder.appendLiteral("</h2>");
if (!feed->m_description.isEmpty()) {
- rc += "<p>";
- rc += feed->m_description;
- rc += "</p>";
+ builder.appendLiteral("<p>");
+ builder.append(feed->m_description);
+ builder.appendLiteral("</p>");
}
for (unsigned i = 0; i < feed->m_items.size(); ++i) {
RSSItem* item = feed->m_items[i];
String articleName;
- rc += "<div id=\"";
- rc += articleName;
- rc += "\" class=\"article\">\n<a href=""
+ builder.appendLiteral("<div id=\"");
+ builder.append(articleName);
+ builder.appendLiteral("\" class=\"article\">\n<a href=""
if (!item->m_link.isEmpty())
- rc += item->m_link.utf8(true).data();
- rc += "\"><b>";
+ builder.append(item->m_link.utf8(true).data());
+ builder.appendLiteral("\"><b>");
if (!item->m_title.isEmpty())
- rc += item->m_title.utf8(true).data();
+ builder.append(item->m_title.utf8(true).data());
else
- rc += s_defaultEntryTitle;
- rc += "</b></a>\n<br />";
+ builder.append(s_defaultEntryTitle);
+ builder.appendLiteral("</b></a>\n<br />");
if (!item->m_author.isEmpty()) {
- rc += i18n("By");
- rc += " <b>";
- rc += item->m_author.utf8(true).data();
- rc += "</b> ";
+ builder.append(i18n("By"));
+ builder.appendLiteral(" <b>");
+ builder.append(item->m_author.utf8(true).data());
+ builder.appendLiteral("</b> ");
} else {
if (!feed->m_author.isEmpty()) {
- rc += i18n("By");
- rc += " <b>";
- rc += feed->m_author.utf8(true).data();
- rc += "</b> ";
+ builder.append(i18n("By"));
+ builder.appendLiteral(" <b>");
+ builder.append(feed->m_author.utf8(true).data());
+ builder.appendLiteral("</b> ");
}
}
if (!item->m_categories.isEmpty()) {
if (!item->m_author.isEmpty())
- rc += i18n("under ");
+ builder.append(i18n("under "));
else
- rc += i18n("Under ");
+ builder.append(i18n("Under "));
for (unsigned i = 0; i < item->m_categories.size() ; ++i) {
- rc += "<b>";
- rc += item->m_categories[i].utf8(true).data();
- rc += "</b>";
+ builder.appendLiteral("<b>");
+ builder.append(item->m_categories[i].utf8(true).data());
+ builder.appendLiteral("</b>");
if (i < item->m_categories.size() - 1)
- rc += ", ";
+ builder.appendLiteral(", ");
}
}
- rc += "<br />";
+ builder.appendLiteral("<br />");
if (!item->m_pubDate.isEmpty())
- rc += item->m_pubDate.utf8(true).data();
+ builder.append(item->m_pubDate.utf8(true).data());
- rc += "<br />";
+ builder.appendLiteral("<br />");
if (!item->m_description.isEmpty())
- rc += item->m_description.utf8(true).data();
- rc += "<br />";
+ builder.append(item->m_description.utf8(true).data());
+ builder.appendLiteral("<br />");
if (item->m_enclosure) {
- rc += "<br />";
- rc += "<a href=""
- rc += item->m_enclosure->m_url;
- rc += "\">";
- rc += i18n("Embedded ");
+ builder.appendLiteral("<br />");
+ builder.appendLiteral("<a href=""
+ builder.append(item->m_enclosure->m_url);
+ builder.appendLiteral("\">");
+ builder.append(i18n("Embedded "));
RSSEnclosure::Type type = item->m_enclosure->typeInEnum();
switch (type) {
case RSSEnclosure::TypeImage:
- rc += i18n("Image");
+ builder.append(i18n("Image"));
break;
case RSSEnclosure::TypeAudio:
- rc += i18n("Audio");
+ builder.append(i18n("Audio"));
break;
case RSSEnclosure::TypeVideo:
- rc += i18n("Video");
+ builder.append(i18n("Video"));
break;
case RSSEnclosure::TypeApplication:
default:
- rc += i18n("Unknown Content");
+ builder.append(i18n("Unknown Content"));
break;
}
- rc += i18n(" Source: ");
- rc += item->m_enclosure->suggestedName();
- rc += "</a><br /><br />";
+ builder.append(i18n(" Source: "));
+ builder.append(item->m_enclosure->suggestedName());
+ builder.appendLiteral("</a><br /><br />");
}
- rc += "<br /></div>\n";
+ builder.appendLiteral("<br /></div>\n");
}
- rc += "</body></html>\n";
+ builder.appendLiteral("</body></html>\n");
- return rc;
+ return builder.toString();
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/network/blackberry/rss/RSSParserBase.cpp (128646 => 128647)
--- trunk/Source/WebCore/platform/network/blackberry/rss/RSSParserBase.cpp 2012-09-14 20:08:09 UTC (rev 128646)
+++ trunk/Source/WebCore/platform/network/blackberry/rss/RSSParserBase.cpp 2012-09-14 20:18:08 UTC (rev 128647)
@@ -21,6 +21,7 @@
#include "libxml/parser.h"
#include "libxml/xmlwriter.h"
+#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -110,14 +111,14 @@
if (!attr)
return emptyString();
- String text;
+ StringBuilder text;
for (xmlNode* node = attr->children; node; node = node->next) {
if (node->type == XML_TEXT_NODE)
- text += reinterpret_cast<const char*>(node->content);
+ text.append(reinterpret_cast<const char*>(node->content));
}
- return text.stripWhiteSpace();
+ return text.toString().stripWhiteSpace();
}
String textFromXMLNode(xmlNode* node)
@@ -125,14 +126,14 @@
if (!node)
return emptyString();
- String text;
+ StringBuilder text;
for (node = node->children; node; node = node->next) {
if ((node->type == XML_TEXT_NODE) || (node->type == XML_CDATA_SECTION_NODE))
- text += reinterpret_cast<const char*>(node->content);
+ text.append(reinterpret_cast<const char*>(node->content));
}
- return text.stripWhiteSpace();
+ return text.toString().stripWhiteSpace();
}
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes