aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/formdata.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/script/dom/formdata.rs')
-rw-r--r--src/components/script/dom/formdata.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/components/script/dom/formdata.rs b/src/components/script/dom/formdata.rs
new file mode 100644
index 00000000000..cda6b7ae272
--- /dev/null
+++ b/src/components/script/dom/formdata.rs
@@ -0,0 +1,38 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use dom::bindings::utils::{WrapperCache, DOMString, str};
+use dom::blob::Blob;
+use std::hashmap::HashMap;
+
+enum FormDatum {
+ StringData(DOMString),
+ BlobData { blob: @mut Blob, name: DOMString }
+}
+
+pub struct FormData {
+ data: HashMap<~str, FormDatum>,
+ wrapper: WrapperCache
+}
+
+impl FormData {
+ pub fn new() -> @mut FormData {
+ @mut FormData {
+ data: HashMap::new(),
+ wrapper: WrapperCache::new()
+ }
+ }
+
+ pub fn Append(&mut self, name: DOMString, value: @mut Blob, filename: Option<DOMString>) {
+ let blob = BlobData {
+ blob: value,
+ name: filename.get_or_default(str(~"default"))
+ };
+ self.data.insert(name.to_str(), blob);
+ }
+
+ pub fn Append_(&mut self, name: DOMString, value: DOMString) {
+ self.data.insert(name.to_str(), StringData(value));
+ }
+} \ No newline at end of file