mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Make Blob create its binding eagerly.
This commit is contained in:
parent
284ad5ee8e
commit
9046085506
1 changed files with 22 additions and 12 deletions
|
@ -4,20 +4,33 @@
|
||||||
|
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
use dom::bindings::codegen::BlobBinding;
|
use dom::bindings::codegen::BlobBinding;
|
||||||
use script_task::{page_from_context};
|
use dom::window::Window;
|
||||||
|
|
||||||
use js::jsapi::{JSContext, JSObject};
|
use js::jsapi::{JSContext, JSObject};
|
||||||
|
|
||||||
pub struct Blob {
|
pub struct Blob {
|
||||||
reflector_: Reflector
|
reflector_: Reflector,
|
||||||
|
window: @mut Window,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Blob {
|
impl Blob {
|
||||||
pub fn new() -> @mut Blob {
|
pub fn new_inherited(window: @mut Window) -> Blob {
|
||||||
@mut Blob {
|
Blob {
|
||||||
reflector_: Reflector::new()
|
reflector_: Reflector::new(),
|
||||||
|
window: window,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new(window: @mut Window) -> @mut Blob {
|
||||||
|
let blob = @mut Blob::new_inherited(window);
|
||||||
|
let cx = window.get_cx();
|
||||||
|
let scope = window.reflector().get_jsobject();
|
||||||
|
if BlobBinding::Wrap(cx, scope, blob).is_null() {
|
||||||
|
fail!("BlobBinding::Wrap failed");
|
||||||
|
}
|
||||||
|
assert!(blob.reflector().get_jsobject().is_not_null());
|
||||||
|
blob
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reflectable for Blob {
|
impl Reflectable for Blob {
|
||||||
|
@ -29,14 +42,11 @@ impl Reflectable for Blob {
|
||||||
&mut self.reflector_
|
&mut self.reflector_
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||||
BlobBinding::Wrap(cx, scope, self)
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut Reflectable> {
|
fn GetParentObject(&self, _cx: *JSContext) -> Option<@mut Reflectable> {
|
||||||
let page = page_from_context(cx);
|
Some(self.window as @mut Reflectable)
|
||||||
unsafe {
|
|
||||||
Some((*page).frame.get_ref().window as @mut Reflectable)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue