diff options
author | Zhen Zhang <izgzhen@gmail.com> | 2016-05-17 12:52:35 +0800 |
---|---|---|
committer | Zhen Zhang <izgzhen@gmail.com> | 2016-06-01 09:47:07 +0800 |
commit | 43ad4ba5857dbcd1a31aaf7e441c5cfe4fe1b84f (patch) | |
tree | ef221985dfe1d3ed54e7a2af31903d8b1dbf40e4 /components/script/dom/formdata.rs | |
parent | d53507f747f7122dc520f5e4a374ee1ad955aa5d (diff) | |
download | servo-43ad4ba5857dbcd1a31aaf7e441c5cfe4fe1b84f.tar.gz servo-43ad4ba5857dbcd1a31aaf7e441c5cfe4fe1b84f.zip |
Add file backend support for Blob and related
Changes include:
- Add BlobImpl to Blob, and related caching mechanism
- Expose ResourceThreads to document_loader, workerglobalscope, worker, and global
- Fix encode_multipart_form_data
- Other small fixes to accommodate the above changes
Diffstat (limited to 'components/script/dom/formdata.rs')
-rw-r--r-- | components/script/dom/formdata.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs index c7521a94365..95b4aae27e2 100644 --- a/components/script/dom/formdata.rs +++ b/components/script/dom/formdata.rs @@ -11,7 +11,7 @@ use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::str::{DOMString, USVString}; -use dom::blob::Blob; +use dom::blob::{Blob, BlobImpl}; use dom::file::File; use dom::htmlformelement::HTMLFormElement; use std::collections::HashMap; @@ -121,14 +121,15 @@ impl FormDataMethods for FormData { impl FormData { - fn get_file_or_blob(&self, value: &Blob, filename: Option<USVString>) -> Root<Blob> { + fn get_file_or_blob(&self, blob: &Blob, filename: Option<USVString>) -> Root<Blob> { match filename { Some(fname) => { let global = self.global(); let name = DOMString::from(fname.0); - Root::upcast(File::new(global.r(), value.get_data().clone(), name, None, "")) + let slice = blob.get_slice_or_empty(); + Root::upcast(File::new(global.r(), BlobImpl::new_from_slice(slice), name, None, "")) } - None => Root::from_ref(value) + None => Root::from_ref(blob) } } } |