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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/DOMFormData.h ('k') | Source/core/html/FormDataList.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 bool DOMFormData::has(const String& name) 159 bool DOMFormData::has(const String& name)
160 { 160 {
161 if (m_opaque) 161 if (m_opaque)
162 return false; 162 return false;
163 return hasEntry(name); 163 return hasEntry(name);
164 } 164 }
165 165
166 void DOMFormData::set(const String& name, const String& value) 166 void DOMFormData::set(const String& name, const String& value)
167 { 167 {
168 setData(name, value); 168 setEntry(Item(encodeAndNormalize(name), encodeAndNormalize(value)));
169 } 169 }
170 170
171 void DOMFormData::set(const String& name, Blob* blob, const String& filename) 171 void DOMFormData::set(const String& name, Blob* blob, const String& filename)
172 { 172 {
173 setBlob(name, blob, filename); 173 setEntry(Item(encodeAndNormalize(name), blob, filename));
174 }
175
176 void DOMFormData::setEntry(const Item& item)
177 {
178 const CString keyData = item.key();
179 bool found = false;
180 size_t i = 0;
181 while (i < m_items.size()) {
182 if (m_items[i].key() != keyData) {
183 ++i;
184 } else if (found) {
185 m_items.remove(i);
186 } else {
187 found = true;
188 m_items[i] = item;
189 ++i;
190 }
191 }
192 if (!found)
193 m_items.append(item);
194 return;
174 } 195 }
175 196
176 PairIterable<String, FormDataEntryValue>::IterationSource* DOMFormData::startIte ration(ScriptState*, ExceptionState&) 197 PairIterable<String, FormDataEntryValue>::IterationSource* DOMFormData::startIte ration(ScriptState*, ExceptionState&)
177 { 198 {
178 if (m_opaque) 199 if (m_opaque)
179 return new DOMFormDataIterationSource(new DOMFormData(nullptr)); 200 return new DOMFormDataIterationSource(new DOMFormData(nullptr));
180 201
181 return new DOMFormDataIterationSource(this); 202 return new DOMFormDataIterationSource(this);
182 } 203 }
183 204
184 } // namespace blink 205 } // namespace blink
OLDNEW
« 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