aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/formdata.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-07-15 20:05:51 +0200
committerMs2ger <ms2ger@gmail.com>2014-07-15 20:08:11 +0200
commit350a6080d7cb267c62dc5ee06dd657393eef1d52 (patch)
treeba1c78953fa590147373aeb4805880e9a2a4bb3c /src/components/script/dom/formdata.rs
parent829259fb794831167c9992bd6b1c71bf81bd8023 (diff)
downloadservo-350a6080d7cb267c62dc5ee06dd657393eef1d52.tar.gz
servo-350a6080d7cb267c62dc5ee06dd657393eef1d52.zip
Support FormData outside Window scopes.
Diffstat (limited to 'src/components/script/dom/formdata.rs')
-rw-r--r--src/components/script/dom/formdata.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/components/script/dom/formdata.rs b/src/components/script/dom/formdata.rs
index 8f5c2cfcd19..221865a4960 100644
--- a/src/components/script/dom/formdata.rs
+++ b/src/components/script/dom/formdata.rs
@@ -6,14 +6,13 @@ use dom::bindings::codegen::Bindings::FormDataBinding;
use dom::bindings::codegen::InheritTypes::FileCast;
use dom::bindings::codegen::UnionTypes::FileOrString::{FileOrString, eFile, eString};
use dom::bindings::error::{Fallible};
-use dom::bindings::global::{GlobalRef, Window};
+use dom::bindings::global::{GlobalRef, GlobalField};
use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::trace::Traceable;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::blob::Blob;
use dom::file::File;
use dom::htmlformelement::HTMLFormElement;
-use dom::window::Window;
use servo_util::str::DOMString;
use std::cell::RefCell;
use std::collections::hashmap::HashMap;
@@ -28,27 +27,27 @@ pub enum FormDatum {
pub struct FormData {
data: Traceable<RefCell<HashMap<DOMString, Vec<FormDatum>>>>,
reflector_: Reflector,
- window: JS<Window>,
+ global: GlobalField,
form: Option<JS<HTMLFormElement>>
}
impl FormData {
- pub fn new_inherited(form: Option<JSRef<HTMLFormElement>>, window: &JSRef<Window>) -> FormData {
+ pub fn new_inherited(form: Option<JSRef<HTMLFormElement>>, global: &GlobalRef) -> FormData {
FormData {
data: Traceable::new(RefCell::new(HashMap::new())),
reflector_: Reflector::new(),
- window: JS::from_rooted(window),
+ global: GlobalField::from_rooted(global),
form: form.map(|f| JS::from_rooted(&f)),
}
}
- pub fn new(form: Option<JSRef<HTMLFormElement>>, window: &JSRef<Window>) -> Temporary<FormData> {
- reflect_dom_object(box FormData::new_inherited(form, window),
- &Window(*window), FormDataBinding::Wrap)
+ pub fn new(form: Option<JSRef<HTMLFormElement>>, global: &GlobalRef) -> Temporary<FormData> {
+ reflect_dom_object(box FormData::new_inherited(form, global),
+ global, FormDataBinding::Wrap)
}
pub fn Constructor(global: &GlobalRef, form: Option<JSRef<HTMLFormElement>>) -> Fallible<Temporary<FormData>> {
- Ok(FormData::new(form, global.as_window()))
+ Ok(FormData::new(form, global))
}
}
@@ -117,9 +116,9 @@ trait PrivateFormDataHelpers{
impl PrivateFormDataHelpers for FormData {
fn get_file_from_blob(&self, value: &JSRef<Blob>, filename: Option<DOMString>) -> Temporary<File> {
- let window = self.window.root();
+ let global = self.global.root();
let f: Option<&JSRef<File>> = FileCast::to_ref(value);
let name = filename.unwrap_or(f.map(|inner| inner.name.clone()).unwrap_or("blob".to_string()));
- File::new(&Window(*window), value, name)
+ File::new(&global.root_ref(), value, name)
}
}