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

Unified Diff: Source/core/html/DOMFormData.cpp

Issue 1320463010: Move FormDataList::setEntry to DOMFormData. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | « Source/core/html/DOMFormData.h ('k') | Source/core/html/FormDataList.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/DOMFormData.cpp
diff --git a/Source/core/html/DOMFormData.cpp b/Source/core/html/DOMFormData.cpp
index 639d035deedc8abf133114999fb3dc7eabedd133..d797beced69bbb0b4de1ba4748764380716da382 100644
--- a/Source/core/html/DOMFormData.cpp
+++ b/Source/core/html/DOMFormData.cpp
@@ -165,12 +165,33 @@ bool DOMFormData::has(const String& name)
void DOMFormData::set(const String& name, const String& value)
{
- setData(name, value);
+ setEntry(Item(encodeAndNormalize(name), encodeAndNormalize(value)));
}
void DOMFormData::set(const String& name, Blob* blob, const String& filename)
{
- setBlob(name, blob, filename);
+ setEntry(Item(encodeAndNormalize(name), blob, filename));
+}
+
+void DOMFormData::setEntry(const Item& item)
+{
+ const CString keyData = item.key();
+ bool found = false;
+ size_t i = 0;
+ while (i < m_items.size()) {
+ if (m_items[i].key() != keyData) {
+ ++i;
+ } else if (found) {
+ m_items.remove(i);
+ } else {
+ found = true;
+ m_items[i] = item;
+ ++i;
+ }
+ }
+ if (!found)
+ m_items.append(item);
+ return;
}
PairIterable<String, FormDataEntryValue>::IterationSource* DOMFormData::startIteration(ScriptState*, ExceptionState&)
« no previous file with comments | « Source/core/html/DOMFormData.h ('k') | Source/core/html/FormDataList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698