| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 const Member<DOMFormData> m_formData; | 72 const Member<DOMFormData> m_formData; |
| 73 size_t m_current; | 73 size_t m_current; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 } // namespace | 76 } // namespace |
| 77 | 77 |
| 78 DOMFormData::DOMFormData(const WTF::TextEncoding& encoding) | 78 DOMFormData::DOMFormData(const WTF::TextEncoding& encoding) |
| 79 : FormDataList(encoding) | 79 : FormDataList(encoding) |
| 80 , m_opaque(false) |
| 80 { | 81 { |
| 81 } | 82 } |
| 82 | 83 |
| 83 DOMFormData::DOMFormData(HTMLFormElement* form) | 84 DOMFormData::DOMFormData(HTMLFormElement* form) |
| 84 : FormDataList(UTF8Encoding()) | 85 : FormDataList(UTF8Encoding()) |
| 86 , m_opaque(false) |
| 85 { | 87 { |
| 86 if (!form) | 88 if (!form) |
| 87 return; | 89 return; |
| 88 | 90 |
| 89 for (unsigned i = 0; i < form->associatedElements().size(); ++i) { | 91 for (unsigned i = 0; i < form->associatedElements().size(); ++i) { |
| 90 FormAssociatedElement* element = form->associatedElements()[i]; | 92 FormAssociatedElement* element = form->associatedElements()[i]; |
| 91 if (!toHTMLElement(element)->isDisabledFormControl()) | 93 if (!toHTMLElement(element)->isDisabledFormControl()) |
| 92 element->appendFormData(*this, true); | 94 element->appendFormData(*this, true); |
| 93 } | 95 } |
| 94 } | 96 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 113 UseCounter::count(context, UseCounter::FormDataAppendBlobWithFil
ename); | 115 UseCounter::count(context, UseCounter::FormDataAppendBlobWithFil
ename); |
| 114 } | 116 } |
| 115 } else { | 117 } else { |
| 116 UseCounter::count(context, UseCounter::FormDataAppendNull); | 118 UseCounter::count(context, UseCounter::FormDataAppendNull); |
| 117 } | 119 } |
| 118 appendBlob(name, blob, filename); | 120 appendBlob(name, blob, filename); |
| 119 } | 121 } |
| 120 | 122 |
| 121 void DOMFormData::get(const String& name, FormDataEntryValue& result) | 123 void DOMFormData::get(const String& name, FormDataEntryValue& result) |
| 122 { | 124 { |
| 125 if (m_opaque) |
| 126 return; |
| 123 Entry entry = getEntry(name); | 127 Entry entry = getEntry(name); |
| 124 if (entry.isString()) | 128 if (entry.isString()) |
| 125 result.setUSVString(entry.string()); | 129 result.setUSVString(entry.string()); |
| 126 else if (entry.isFile()) | 130 else if (entry.isFile()) |
| 127 result.setFile(entry.file()); | 131 result.setFile(entry.file()); |
| 128 else | 132 else |
| 129 ASSERT(entry.isNone()); | 133 ASSERT(entry.isNone()); |
| 130 } | 134 } |
| 131 | 135 |
| 132 HeapVector<FormDataEntryValue> DOMFormData::getAll(const String& name) | 136 HeapVector<FormDataEntryValue> DOMFormData::getAll(const String& name) |
| 133 { | 137 { |
| 134 HeapVector<FormDataEntryValue> results; | 138 HeapVector<FormDataEntryValue> results; |
| 139 |
| 140 if (m_opaque) |
| 141 return results; |
| 142 |
| 135 HeapVector<FormDataList::Entry> entries = FormDataList::getAll(name); | 143 HeapVector<FormDataList::Entry> entries = FormDataList::getAll(name); |
| 136 for (const FormDataList::Entry& entry : entries) { | 144 for (const FormDataList::Entry& entry : entries) { |
| 137 ASSERT(entry.name() == name); | 145 ASSERT(entry.name() == name); |
| 138 FormDataEntryValue value; | 146 FormDataEntryValue value; |
| 139 if (entry.isString()) | 147 if (entry.isString()) |
| 140 value.setUSVString(entry.string()); | 148 value.setUSVString(entry.string()); |
| 141 else if (entry.isFile()) | 149 else if (entry.isFile()) |
| 142 value.setFile(entry.file()); | 150 value.setFile(entry.file()); |
| 143 else | 151 else |
| 144 ASSERT_NOT_REACHED(); | 152 ASSERT_NOT_REACHED(); |
| 145 results.append(value); | 153 results.append(value); |
| 146 } | 154 } |
| 147 ASSERT(results.size() == entries.size()); | 155 ASSERT(results.size() == entries.size()); |
| 148 return results; | 156 return results; |
| 149 } | 157 } |
| 150 | 158 |
| 159 bool DOMFormData::has(const String& name) |
| 160 { |
| 161 if (m_opaque) |
| 162 return false; |
| 163 return hasEntry(name); |
| 164 } |
| 165 |
| 151 void DOMFormData::set(const String& name, const String& value) | 166 void DOMFormData::set(const String& name, const String& value) |
| 152 { | 167 { |
| 153 setData(name, value); | 168 setData(name, value); |
| 154 } | 169 } |
| 155 | 170 |
| 156 void DOMFormData::set(const String& name, Blob* blob, const String& filename) | 171 void DOMFormData::set(const String& name, Blob* blob, const String& filename) |
| 157 { | 172 { |
| 158 setBlob(name, blob, filename); | 173 setBlob(name, blob, filename); |
| 159 } | 174 } |
| 160 | 175 |
| 161 PairIterable<String, FormDataEntryValue>::IterationSource* DOMFormData::startIte
ration(ScriptState*, ExceptionState&) | 176 PairIterable<String, FormDataEntryValue>::IterationSource* DOMFormData::startIte
ration(ScriptState*, ExceptionState&) |
| 162 { | 177 { |
| 178 if (m_opaque) |
| 179 return new DOMFormDataIterationSource(new DOMFormData(nullptr)); |
| 180 |
| 163 return new DOMFormDataIterationSource(this); | 181 return new DOMFormDataIterationSource(this); |
| 164 } | 182 } |
| 165 | 183 |
| 166 } // namespace blink | 184 } // namespace blink |
| OLD | NEW |