Add global default method for Reflectable trait

This commit is contained in:
Chad Kimes 2016-01-10 23:08:55 -05:00
parent 2703568227
commit ce6075825d
17 changed files with 88 additions and 83 deletions

View file

@ -4,7 +4,7 @@
//! The `Reflector` struct.
use dom::bindings::global::GlobalRef;
use dom::bindings::global::{GlobalRef, GlobalRoot, global_root_from_reflector};
use dom::bindings::js::Root;
use js::jsapi::{HandleObject, JSContext, JSObject};
use std::cell::UnsafeCell;
@ -75,4 +75,9 @@ pub trait Reflectable {
fn reflector(&self) -> &Reflector;
/// Initializes the Reflector
fn init_reflector(&mut self, obj: *mut JSObject);
/// Returns the global object of the realm that the Reflectable was created in.
fn global(&self) -> GlobalRoot where Self: Sized {
global_root_from_reflector(self)
}
}