aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/formdata.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-07-15 22:28:43 +0200
committerMs2ger <ms2ger@gmail.com>2014-07-15 22:28:43 +0200
commitd97ec6995773ee79fbde053520bc580e7b33d15d (patch)
treee5a00cefa1309b80bc8a44287c3cc9059ed4a257 /src/components/script/dom/formdata.rs
parentf816a92c72e2eb60f733b2cd7072c8542710d5ae (diff)
parentdf9d063b36aca184a336b9e67da3ce30bb46cb79 (diff)
downloadservo-d97ec6995773ee79fbde053520bc580e7b33d15d.tar.gz
servo-d97ec6995773ee79fbde053520bc580e7b33d15d.zip
Merge pull request #2839 from Ms2ger/globals
Introduce abstractions for global scopes; r=Manishearth,larsberg
Diffstat (limited to 'src/components/script/dom/formdata.rs')
-rw-r--r--src/components/script/dom/formdata.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/components/script/dom/formdata.rs b/src/components/script/dom/formdata.rs
index 1986c4f2f96..221865a4960 100644
--- a/src/components/script/dom/formdata.rs
+++ b/src/components/script/dom/formdata.rs
@@ -6,13 +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, 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;
@@ -27,26 +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, 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(window: &JSRef<Window>, form: Option<JSRef<HTMLFormElement>>) -> Fallible<Temporary<FormData>> {
- Ok(FormData::new(form, window))
+ pub fn Constructor(global: &GlobalRef, form: Option<JSRef<HTMLFormElement>>) -> Fallible<Temporary<FormData>> {
+ Ok(FormData::new(form, global))
}
}
@@ -115,9 +116,9 @@ trait PrivateFormDataHelpers{
impl PrivateFormDataHelpers for FormData {
fn get_file_from_blob(&self, value: &JSRef<Blob>, filename: Option<DOMString>) -> Temporary<File> {
- let global = 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(&*global, value, name)
+ File::new(&global.root_ref(), value, name)
}
}