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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } else { | 130 } else { |
131 ++i; | 131 ++i; |
132 } | 132 } |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 void DOMFormData::get(const String& name, FormDataEntryValue& result) | 136 void DOMFormData::get(const String& name, FormDataEntryValue& result) |
137 { | 137 { |
138 if (m_opaque) | 138 if (m_opaque) |
139 return; | 139 return; |
140 Entry entry = getEntry(name); | 140 const CString encodedName = encodeAndNormalize(name); |
141 if (entry.isString()) | 141 for (const Item& entry : items()) { |
142 result.setUSVString(entry.string()); | 142 if (entry.key() == encodedName) { |
143 else if (entry.isFile()) | 143 if (entry.isString()) { |
144 result.setFile(entry.file()); | 144 result.setUSVString(decode(entry.data())); |
145 else | 145 } else { |
146 ASSERT(entry.isNone()); | 146 ASSERT(entry.isFile()); |
| 147 result.setFile(entry.file()); |
| 148 } |
| 149 return; |
| 150 } |
| 151 } |
147 } | 152 } |
148 | 153 |
149 HeapVector<FormDataEntryValue> DOMFormData::getAll(const String& name) | 154 HeapVector<FormDataEntryValue> DOMFormData::getAll(const String& name) |
150 { | 155 { |
151 HeapVector<FormDataEntryValue> results; | 156 HeapVector<FormDataEntryValue> results; |
152 | 157 |
153 if (m_opaque) | 158 if (m_opaque) |
154 return results; | 159 return results; |
155 | 160 |
156 HeapVector<FormDataList::Entry> entries = FormDataList::getAll(name); | 161 const CString encodedName = encodeAndNormalize(name); |
157 for (const FormDataList::Entry& entry : entries) { | 162 for (const Item& entry : items()) { |
158 ASSERT(entry.name() == name); | 163 if (entry.key() != encodedName) |
| 164 continue; |
159 FormDataEntryValue value; | 165 FormDataEntryValue value; |
160 if (entry.isString()) | 166 if (entry.isString()) { |
161 value.setUSVString(entry.string()); | 167 value.setUSVString(decode(entry.data())); |
162 else if (entry.isFile()) | 168 } else { |
| 169 ASSERT(entry.isFile()); |
163 value.setFile(entry.file()); | 170 value.setFile(entry.file()); |
164 else | 171 } |
165 ASSERT_NOT_REACHED(); | |
166 results.append(value); | 172 results.append(value); |
167 } | 173 } |
168 ASSERT(results.size() == entries.size()); | |
169 return results; | 174 return results; |
170 } | 175 } |
171 | 176 |
172 bool DOMFormData::has(const String& name) | 177 bool DOMFormData::has(const String& name) |
173 { | 178 { |
174 if (m_opaque) | 179 if (m_opaque) |
175 return false; | 180 return false; |
176 const CString keyData = encodeAndNormalize(name); | 181 const CString keyData = encodeAndNormalize(name); |
177 for (const Item& item : items()) { | 182 for (const Item& item : items()) { |
178 if (item.key() == keyData) | 183 if (item.key() == keyData) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 224 |
220 PairIterable<String, FormDataEntryValue>::IterationSource* DOMFormData::startIte
ration(ScriptState*, ExceptionState&) | 225 PairIterable<String, FormDataEntryValue>::IterationSource* DOMFormData::startIte
ration(ScriptState*, ExceptionState&) |
221 { | 226 { |
222 if (m_opaque) | 227 if (m_opaque) |
223 return new DOMFormDataIterationSource(new DOMFormData(nullptr)); | 228 return new DOMFormDataIterationSource(new DOMFormData(nullptr)); |
224 | 229 |
225 return new DOMFormDataIterationSource(this); | 230 return new DOMFormDataIterationSource(this); |
226 } | 231 } |
227 | 232 |
228 } // namespace blink | 233 } // namespace blink |
OLD | NEW |