Introduce Reflectable::global_scope

This commit is contained in:
Anthony Ramine 2016-10-01 18:15:15 +02:00
parent 27f100b1d4
commit ae6af5172b
30 changed files with 116 additions and 120 deletions

View file

@ -5,7 +5,7 @@
//! The `Reflector` struct.
use dom::bindings::conversions::DerivedFrom;
use dom::bindings::global::{GlobalRoot, global_root_from_reflector};
use dom::bindings::global::{GlobalRoot, global_root_from_reflector, global_scope_from_reflector};
use dom::bindings::js::Root;
use dom::globalscope::GlobalScope;
use js::jsapi::{HandleObject, JSContext, JSObject};
@ -80,6 +80,11 @@ pub trait Reflectable {
/// Returns the receiver's reflector.
fn reflector(&self) -> &Reflector;
/// Returns the global scope of the realm that the Reflectable was created in.
fn global_scope(&self) -> Root<GlobalScope> where Self: Sized {
global_scope_from_reflector(self)
}
/// 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)