| OLD | NEW |
| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 if (!toHTMLElement(element)->isDisabledFormControl()) | 89 if (!toHTMLElement(element)->isDisabledFormControl()) |
| 90 element->appendToFormData(*this); | 90 element->appendToFormData(*this); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 DEFINE_TRACE(FormData) { | 94 DEFINE_TRACE(FormData) { |
| 95 visitor->trace(m_entries); | 95 visitor->trace(m_entries); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void FormData::append(const String& name, const String& value) { | 98 void FormData::append(const String& name, const String& value) { |
| 99 m_entries.append( | 99 m_entries.push_back( |
| 100 new Entry(encodeAndNormalize(name), encodeAndNormalize(value))); | 100 new Entry(encodeAndNormalize(name), encodeAndNormalize(value))); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void FormData::append(ExecutionContext* context, | 103 void FormData::append(ExecutionContext* context, |
| 104 const String& name, | 104 const String& name, |
| 105 Blob* blob, | 105 Blob* blob, |
| 106 const String& filename) { | 106 const String& filename) { |
| 107 if (blob) { | 107 if (blob) { |
| 108 if (blob->isFile()) { | 108 if (blob->isFile()) { |
| 109 if (filename.isNull()) | 109 if (filename.isNull()) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 for (const auto& entry : entries()) { | 156 for (const auto& entry : entries()) { |
| 157 if (entry->name() != encodedName) | 157 if (entry->name() != encodedName) |
| 158 continue; | 158 continue; |
| 159 FormDataEntryValue value; | 159 FormDataEntryValue value; |
| 160 if (entry->isString()) { | 160 if (entry->isString()) { |
| 161 value.setUSVString(decode(entry->value())); | 161 value.setUSVString(decode(entry->value())); |
| 162 } else { | 162 } else { |
| 163 DCHECK(entry->isFile()); | 163 DCHECK(entry->isFile()); |
| 164 value.setFile(entry->file()); | 164 value.setFile(entry->file()); |
| 165 } | 165 } |
| 166 results.append(value); | 166 results.push_back(value); |
| 167 } | 167 } |
| 168 return results; | 168 return results; |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool FormData::has(const String& name) { | 171 bool FormData::has(const String& name) { |
| 172 const CString encodedName = encodeAndNormalize(name); | 172 const CString encodedName = encodeAndNormalize(name); |
| 173 for (const auto& entry : entries()) { | 173 for (const auto& entry : entries()) { |
| 174 if (entry->name() == encodedName) | 174 if (entry->name() == encodedName) |
| 175 return true; | 175 return true; |
| 176 } | 176 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 195 ++i; | 195 ++i; |
| 196 } else if (found) { | 196 } else if (found) { |
| 197 m_entries.remove(i); | 197 m_entries.remove(i); |
| 198 } else { | 198 } else { |
| 199 found = true; | 199 found = true; |
| 200 m_entries[i] = entry; | 200 m_entries[i] = entry; |
| 201 ++i; | 201 ++i; |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 if (!found) | 204 if (!found) |
| 205 m_entries.append(entry); | 205 m_entries.push_back(entry); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void FormData::append(const String& name, int value) { | 208 void FormData::append(const String& name, int value) { |
| 209 append(name, String::number(value)); | 209 append(name, String::number(value)); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void FormData::append(const String& name, Blob* blob, const String& filename) { | 212 void FormData::append(const String& name, Blob* blob, const String& filename) { |
| 213 m_entries.append(new Entry(encodeAndNormalize(name), blob, filename)); | 213 m_entries.push_back(new Entry(encodeAndNormalize(name), blob, filename)); |
| 214 } | 214 } |
| 215 | 215 |
| 216 CString FormData::encodeAndNormalize(const String& string) const { | 216 CString FormData::encodeAndNormalize(const String& string) const { |
| 217 CString encodedString = | 217 CString encodedString = |
| 218 m_encoding.encode(string, WTF::EntitiesForUnencodables); | 218 m_encoding.encode(string, WTF::EntitiesForUnencodables); |
| 219 return normalizeLineEndingsToCRLF(encodedString); | 219 return normalizeLineEndingsToCRLF(encodedString); |
| 220 } | 220 } |
| 221 | 221 |
| 222 String FormData::decode(const CString& data) const { | 222 String FormData::decode(const CString& data) const { |
| 223 return encoding().decode(data.data(), data.length()); | 223 return encoding().decode(data.data(), data.length()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 return file->clone(filename()); | 338 return file->clone(filename()); |
| 339 } | 339 } |
| 340 | 340 |
| 341 String filename = m_filename; | 341 String filename = m_filename; |
| 342 if (filename.isNull()) | 342 if (filename.isNull()) |
| 343 filename = "blob"; | 343 filename = "blob"; |
| 344 return File::create(filename, currentTimeMS(), blob()->blobDataHandle()); | 344 return File::create(filename, currentTimeMS(), blob()->blobDataHandle()); |
| 345 } | 345 } |
| 346 | 346 |
| 347 } // namespace blink | 347 } // namespace blink |
| OLD | NEW |