Partial implementation of FormData and File

This commit is contained in:
Manish Goregaokar 2014-06-03 18:56:57 +05:30
parent 0547609589
commit 06eb08ab70
7 changed files with 160 additions and 14 deletions

View file

@ -2,23 +2,32 @@
* 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::codegen::InheritTypes::FileDerived;
use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::error::Fallible;
use dom::bindings::codegen::Bindings::BlobBinding;
use dom::window::Window;
#[deriving(Encodable)]
pub enum BlobType {
BlobTypeId,
FileTypeId
}
#[deriving(Encodable)]
pub struct Blob {
pub reflector_: Reflector,
pub window: JS<Window>
pub window: JS<Window>,
pub type_: BlobType
}
impl Blob {
pub fn new_inherited(window: &JSRef<Window>) -> Blob {
Blob {
reflector_: Reflector::new(),
window: JS::from_rooted(window)
window: JS::from_rooted(window),
type_: BlobTypeId
}
}
@ -41,3 +50,12 @@ impl Reflectable for Blob {
&self.reflector_
}
}
impl FileDerived for Blob {
fn is_file(&self) -> bool {
match self.type_ {
FileTypeId => true,
_ => false
}
}
}