diff options
author | Josh Matthews <josh@joshmatthews.net> | 2013-06-27 18:41:06 +0100 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2013-07-03 15:18:05 -0400 |
commit | eb95d82fe6054c12f8cd50fde90c9c3de794459e (patch) | |
tree | dcb10d58fe09223542a75f4307930d902a8daeed /src/components/script/dom/formdata.rs | |
parent | 213d9a011a63842434df4e8ce3c359d08232aefa (diff) | |
download | servo-eb95d82fe6054c12f8cd50fde90c9c3de794459e.tar.gz servo-eb95d82fe6054c12f8cd50fde90c9c3de794459e.zip |
Implement WebIDL method overloads. Fixes #540.
Diffstat (limited to 'src/components/script/dom/formdata.rs')
-rw-r--r-- | src/components/script/dom/formdata.rs | 38 |
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 |