Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: WebCore/html/FormDataList.cpp

Issue 1769002: BlobBuilder/FormData refactor attempt (Closed)
Patch Set: back to simple FormData Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « WebCore/html/FormDataList.h ('k') | WebCore/html/HTMLFormElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: WebCore/html/FormDataList.cpp
diff --git a/WebCore/html/FormDataList.cpp b/WebCore/html/FormDataList.cpp
index 281c9fe418e1c4833bb87f82f74f1cc4d722d57c..0f62595ed41c2319bdb79b57bbd7ca94622b82aa 100644
--- a/WebCore/html/FormDataList.cpp
+++ b/WebCore/html/FormDataList.cpp
@@ -28,64 +28,22 @@ FormDataList::FormDataList(const TextEncoding& c)
{
}
-void FormDataList::appendString(const CString& s)
+void FormDataList::appendString(const String& s)
{
- m_list.append(s);
+ m_items.append(StringBlobItem::create(s, EndingCRLF, m_encoding));
}
-// Change plain CR and plain LF to CRLF pairs.
-static CString fixLineBreaks(const CString& s)
+void FormDataList::appendString(const CString& s)
{
- // Compute the length.
- unsigned newLen = 0;
- const char* p = s.data();
- while (char c = *p++) {
- if (c == '\r') {
- // Safe to look ahead because of trailing '\0'.
- if (*p != '\n') {
- // Turn CR into CRLF.
- newLen += 2;
- }
- } else if (c == '\n') {
- // Turn LF into CRLF.
- newLen += 2;
- } else {
- // Leave other characters alone.
- newLen += 1;
- }
- }
- if (newLen == s.length()) {
- return s;
- }
-
- // Make a copy of the string.
- p = s.data();
- char* q;
- CString result = CString::newUninitialized(newLen, q);
- while (char c = *p++) {
- if (c == '\r') {
- // Safe to look ahead because of trailing '\0'.
- if (*p != '\n') {
- // Turn CR into CRLF.
- *q++ = '\r';
- *q++ = '\n';
- }
- } else if (c == '\n') {
- // Turn LF into CRLF.
- *q++ = '\r';
- *q++ = '\n';
- } else {
- // Leave other characters alone.
- *q++ = c;
- }
- }
- return result;
+ m_items.append(StringBlobItem::create(s));
}
-void FormDataList::appendString(const String& s)
+void FormDataList::appendBlob(const String& key, PassRefPtr<Blob> blob)
{
- CString cstr = fixLineBreaks(m_encoding.encode(s.characters(), s.length(), EntitiesForUnencodables));
- m_list.append(cstr);
+ appendString(key);
+ const BlobItemList& items = blob->items();
+ for (size_t i = 0; i < items.size(); ++i)
+ m_items.append(items.at(i));
}
} // namespace
« no previous file with comments | « WebCore/html/FormDataList.h ('k') | WebCore/html/HTMLFormElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698