mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
auto merge of #1090 : Ms2ger/servo/blob-eager-binding, r=jdm
This commit is contained in:
commit
2e1cc08413
2 changed files with 32 additions and 14 deletions
|
@ -4,11 +4,12 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.w3.org/TR/2012/WD-dom-20120105/
|
||||
* http://dev.w3.org/2006/webapi/FileAPI/
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
[Constructor]
|
||||
interface Blob {
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,21 +3,41 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
use dom::bindings::utils::Fallible;
|
||||
use dom::bindings::codegen::BlobBinding;
|
||||
use script_task::{page_from_context};
|
||||
use dom::window::Window;
|
||||
|
||||
use js::jsapi::{JSContext, JSObject};
|
||||
|
||||
pub struct Blob {
|
||||
reflector_: Reflector
|
||||
reflector_: Reflector,
|
||||
window: @mut Window,
|
||||
}
|
||||
|
||||
impl Blob {
|
||||
pub fn new() -> @mut Blob {
|
||||
@mut Blob {
|
||||
reflector_: Reflector::new()
|
||||
pub fn new_inherited(window: @mut Window) -> Blob {
|
||||
Blob {
|
||||
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 Blob {
|
||||
pub fn Constructor(window: @mut Window) -> Fallible<@mut Blob> {
|
||||
Ok(Blob::new(window))
|
||||
}
|
||||
}
|
||||
|
||||
impl Reflectable for Blob {
|
||||
|
@ -29,14 +49,11 @@ impl Reflectable for Blob {
|
|||
&mut self.reflector_
|
||||
}
|
||||
|
||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
||||
BlobBinding::Wrap(cx, scope, self)
|
||||
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut Reflectable> {
|
||||
let page = page_from_context(cx);
|
||||
unsafe {
|
||||
Some((*page).frame.get_ref().window as @mut Reflectable)
|
||||
}
|
||||
fn GetParentObject(&self, _cx: *JSContext) -> Option<@mut Reflectable> {
|
||||
Some(self.window as @mut Reflectable)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue