fune/servo/components/script/dom/blob.rs
Michael Booth 8b0b657cb0 servo: Merge #4156 - Updated reflect_dom_object to be passed by value fixes #4122 (from Michael03:master); r=Ms2ger
This fixes issue #4122

Source-Repo: https://github.com/servo/servo
Source-Revision: ed45aa9efd6cf238a83fcae6a772886df61771f7
2014-12-02 05:24:49 -07:00

56 lines
1.3 KiB
Rust

/* 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::codegen::InheritTypes::FileDerived;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::Temporary;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::error::Fallible;
use dom::bindings::codegen::Bindings::BlobBinding;
#[jstraceable]
pub enum BlobType {
BlobTypeId,
FileTypeId
}
#[dom_struct]
pub struct Blob {
reflector_: Reflector,
type_: BlobType
}
impl Blob {
pub fn new_inherited() -> Blob {
Blob {
reflector_: Reflector::new(),
type_: BlobTypeId
}
}
pub fn new(global: GlobalRef) -> Temporary<Blob> {
reflect_dom_object(box Blob::new_inherited(),
global,
BlobBinding::Wrap)
}
pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<Blob>> {
Ok(Blob::new(*global))
}
}
impl Reflectable for Blob {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
}
impl FileDerived for Blob {
fn is_file(&self) -> bool {
match self.type_ {
FileTypeId => true,
_ => false
}
}
}